I have a script as follows:
var1=some_val1
var2=some_val2
var3=some_val3
varX=another_script.sh ${var1} ${var2} ${var3}
I get the following error:
./script.sh: line 5: some_val1: command not found
How do I get it to run properly? The script basically takes these parameters and runs a Hive query. If I put the Hive query back instead of another_script.sh blah blah blah, it works perfectly and the variable captures the value for use later on in the script just fine. I tried swapping it to make it more abstract and I am running into this issue. Please help. Thanks!
a=b command arg1 arg2, which runscommandwith the environment variableaset to valueb. Thus, you're setting environment variablevarXto the valueanother_script.shwhile running the command named byvar1(presuming that expands to exactly one word, which isn't guaranteed unless you fix your quoting).vars=( some_val1 some_val2 some_val3 ); another_script.sh "${vars[@]}", but that's a different discussion..shextension is somewhat frowned on -- if you rewroteanother_scriptin, say, Python or Ruby, you'd need to either change every caller to use the new extension or have it be named inaccurately -- and by convention, UNIX commands don't have extensions anyhow; you don't runls.elf, after all, you just runls. More haranguing on that topic at talisman.org/~erlkonig/documents/…)..shin the command name -- you'd call it asanother_script, notanother_script.sh, but yes, it would work just as well. It's the#!/bin/shor#!/bin/bashline that tells the operating system to treat it as a shell script (and which kind of shell script to treat it as -- the former is pure POSIX, the latter is bash, and others exist as well); the.shextension has no functional effect at all.