I am having problems running SSH from a shell script once I send the script into the background. The error is "expected more tokens" I read on line that I could nest the SSH call in a bash command as follows, but doing so prompts for a password, and even when I enter the correct password (which I don't want to do) it won't work.
This prompts for password from the command line
bash -c "ssh NJ\\NJDSSINFADM@dc01nj2dwifdv02.nj.core.him pmcmds DFD_ETIME wf_TEST"
This works from the command line or script in the foreground, but not when I run the script in the background
ssh NJ\\NJDSSINFADM@dc01nj2dwifdv02.nj.core.him pmcmds DFD_ETIME wf_TEST
Don't use let
to assign variables with strings. It treats the value as an arithmetic expression, and your value is not intended to be treated that way.
jstat=$(echo $jstat|sed -e 's/[^0-9]//g')
You also don't need to use an external command to remove characters from a string, you can use the parameter expansion operator for substitution.
jstat=${jstat//[^0-9]/}
See the Bash Manual for an explanation of this syntax.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.