I am making a script in which i am copying another script to another box and then doing ssh to that server and executing it over there. The issue i am having is that i am passing the parameters to the script however the parameters is not being received by the script on the serevr. Below is my script and its output
#Author: Rohit Bhanot
## Variable defination and declration ##
PS3="Please enter your choice : "
USAGE="bash call.sh <server_name>"
echo "Value of opt is $OPT"
for serv in $LIST
scp rohit.sh root@$serv:/tmp > /dev/null
# ssh $serv 'bash' '/tmp/rohit.sh "$OPT"; rm -f /root/rohit.sh'
ssh $serv -q '/tmp/rohit.sh "$OPT"; rm -f /root/rohit.sh'
if [ "$#" == "0" ];
echo "Missing parameters, this script requires atleast one parameter !!"
echo -e "Correct usage is -- $USAGE \n"
select i in $LIST
case $i in
"Adapter Info" )
CALL Adapter_Info $VAR ;;
#rm -f $0
CALL Exit ;;
Below is the script rohit.sh which i am calling
echo "The value of param is $1"
And here is the output
:/ #bash call serv2
1) Adapter Info
Please enter your choice : 2
Value of opt is Adapter_Info
The value of param is
So can anyone suggest me how to pass the source this script by passing arguements to it. I have tested this method and it worked when both the scripts are on local machine but i want to source the script which is on remote host and pass args to it.