Using grave accent into rsh script.
Hi gurus!
Can anybody explain me if exist possibility using grave accent with rsh syntax. Here below piece of script -> [root@noaapp1 ROOT_ACTIVE_CRON]# rsh racdev1 -l oraint ". .bash_profile; > do > list_files="1 2 3 4 5 6 7" > for i in `echo ${list_files}` > do > echo $i > sleep 1 > done " and I recieved error. bash: -c: line 1: syntax error near unexpected token `do' bash: -c: line 1: `do' Thanks and best regards, Staas. |
Please use [CODE][/CODE] tags around your code. Here is your command, with color and whitespace added for clarity and emphasis:
Quote:
Quoting: After oraint, you supply 7 parameters to rsh. The first parameter ends with 1, the second parameter is 2, and so on; the final parameter starts with 7. If you do not understand why this is, read the Quoting section in the Bash reference manual. The first do is an error. There is no reason for it. Backticks within a double-quoted string: the command within the backticks is run on the current machine, and whatever it yields, is inserted into the double-quoted string before it is given to rsh. Besides, you should be using $(...) instead of `...` (unless the default shell on the remote system is an ancient Unix Bourne shell -- and I don't think so, because you're explicitly sourcing .bash_profile on the remote machine). for i in $(echo ${variable});: No, do not do that. It applies pathname expansion twice, and you do not want nor need that. Typical use would be for i in ${variable};, where the value of variable will be split and pathname expansion applied, and i will loop over the results. Finally, are you sure you wish to use rsh and not ssh (with key-based authentication)? Consider using something like Code:
ssh -l oraint racdev1 bash -c 'for i in 1 2 3 4 5 6 7; do echo $i; sleep 1; done' Code:
ssl -l oraint racdev1 bash -c '"list=(1 2 3 4 5 6 7)"'; for i in "${list[@]}" ; do echo "$i" ; sleep 1 ; done' |
Hi!
Thanks you correct. I am not paste proper code. Please inpect below -> [root@noaapp1 tmp]# rsh racdev1 ". .bash_profile; list_files="1 2 3 4 5 6 7" for i in `echo ${list_files}` do echo $i sleep 1 done" bash: line 1: 2: command not found Thanks Staas. |
yes, it is the same:
rsh host command command is now: ". .bash_profile; list_files="1 described by "some text" and the 1 coming immediately after " and the following 2 3 4 5 6 .... have no meaning. That's why you got 2: command not found. |
All times are GMT -5. The time now is 02:28 AM. |