I have a program that creates a dynamic shell script using heredoc "stop_remoteServer_script.sh"
template of heredoc below
cat<<_STOP > stop_remoteServer_script.sh#!/bin/bashserverName=\$1function getServerpid { pid=\$( ps -ef|grep \${serverName}|grep -v grep |awk '{print \$2}' ) echo \$pid}function kill_soaServer { echo "Killing \${serverName} ........" ps -ef|grep \${serverName} |grep -v grep|awk '{print \$2}'|xargs kill -9 echo "status of killing server is $?"}check_soaServer=\$( getServerpid );while [[ "X\${check_soaServer}" != "X" ]]do cmd_status=\$( kill_soaServer ) sleep 30s check_soaServer=\$( getServerpid )donekill_soaServer \${serverName}_STOP
actual script that goes to remote box for execution
template output
#!/bin/bashserverName=$1function getServerpid { pid=$( ps -ef|grep ${serverName}|grep -v grep |awk '{print $2}' ) echo $pid}function kill_soaServer { echo "Killing ${serverName} ........" ps -ef|grep ${serverName} |grep -v grep|awk '{print $2}'|xargs kill -9 echo "status of killing server is 0"}check_soaServer=$( getServerpid );while [[ "X${check_soaServer}" != "X" ]]do cmd_status=$( kill_soaServer ) sleep 30s check_soaServer=$( getServerpid )donekill_soaServer ${serverName}
Now I have a below expect block of code which will invoke the above generated code in remote box with a parameter of server name
sName=$1CMD="ssh -o StrictHostKeyChecking=no ${remoteUserName}\@${remoteHostName} "# script with parameterscript="./stop_remoteServer_script.sh ${sName}"/usr/bin/expect<<ENDset force_conservative 0spawn bash -c "${CMD} /bin/bash < ${script} "expect "* password: "send -- "${MYPWD}\r"expect "*$*"expect eofEND
The error I am getting is below
spawn bash -c ssh -o StrictHostKeyChecking=no sgngli@den00qoc.us.sdc.com /bin/bash < ./stop_remoteServer_script.sh soa_server2sgngli@den00qoc.us.sdc.com's password:/bin/bash: soa_server2: No such file or directory
can any one help me how to send the parameter , manually it works