Hi,
I'm creating a script where I connet to a remote machine, I execute a command (I get a pid of an application) and I kill the application.
I wrote this:
ssh $HOST_WHITEBOARD<<END
COMMAND_GET_PID_WHITE="ps aux | grep something | awk '/Sl+/ {print \$2}' | awk 'begin {row=0} row==0 {print; row++} row>0 {next}'"
echo "Command to execute: $COMMAND_GET_PID_WHITE"
echo "Try to take il PID"
PID=`eval $COMMAND_GET_PID_WHITE`
echo "Pid: $PID"
kill -9 $PID
END
I have the problem in these lines:
COMMAND_GET_PID_WHITE="ps aux | grep something | awk '/Sl+/ {print \$2}' | awk 'begin {row=0} row==0 {print; row++} row>0 {next}'"
echo "Command to execute: $COMMAND_GET_PID_WHITE"
the echo of COMMAND_GET_PID_WHITE is an empty string. Why? How can I solve?
Thanks, bye bye.
What happens when you put double quotes around END ?
ssh $HOST_WHITEBOARD<<"END"
Thanks a lot!
With:
ssh $HOST_WHITEBOARD<<"END"
it works!
Why do I have to put "?
Thanks again.
Bye bye.
Hi abdujaparov,
From man sh:
<<[-]word The shell input is read up to a line that is the same as
word after any quoting has been removed, or to an end-of-
file. No parameter substitution, command substitution,
arithmetic substitution or file name generation is per-
formed on word. The resulting document, called a here-
document, becomes the standard input. If any character of
word is quoted, then no interpretation is placed upon the
characters of the document. Otherwise, parameter expan-
sion, command substitution, and arithmetic substitution
occur, \NEWLINE is ignored, and \ must be used to quote
the characters \, $, `.
S.