shell - Passing params to another Bash file, with spaces -


i want pass several parameters 1 bash file another, problem is, seems ignore quote marks, dont want pass $@.

here current setup:

agent.sh:

#!/bin/bash  key='insert_key_here';  resp='command start test "srcds_run -game garrysmod +maxplayers 32 +map gm_construct"'  ./cmd.sh ${key} ${resp} 

actually resp coming curl gives me same result.

cmd.sh:

#!/bin/bash  echo $1; echo $2; echo $3; echo $4; echo $5; 

and guess, $5 gives me:

"srcds_run 

instead of

srcds_run -game garrysmod +maxplayers 32 +map gm_construct 

what wanted.

so when using $* gives me parameters, fine want them splitted, same using $@, overwrite parameters @ angent.sh script turns parameters $2 , want them splitted...

so solution pass parameters spaces without issues?

in case have use array (and more quotes):

#!/bin/bash  key='insert_key_here'  resp=( command start test "srcds_run -game garrysmod +maxplayers 32 +map gm_construct" )  ./cmd.sh "$key" "${resp[@]}" 

note used lowercase variable names (which practice!).


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -