Not getting any ouput when running Linux bash script

1152405 pts.
Tags:
Bash
Linux
My friend and I are working on a scripting project that involves Bash. Here's what our script looks like:
#!/bin/bash

VAR1="$1"
VAR2="$2"

MOREF='sudo run command against $VAR1 | grep name | cut -c7-'

echo $MOREF
But when we run the script from the command line and pass it through the arguments, we're not getting any output. But when we run the command with the MOREF variable, we get the output. Why is this happening? Thank you.
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

Typography can be misleading, but it looks as if you are using single quotes in the line where you define the variable MOREF. That will just define it. If you use back-quotes (top left on a US keyboard) the command will be executed as a sub-process to your script. Try that.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: