V
V
vldanch2019-09-06 13:10:53
linux
vldanch, 2019-09-06 13:10:53

How to pass a variable from one sh file to another with sending via ssh?

I pass certain parameters on the command line, they are in the sh file, I need to transfer a variable from one sh file to another sh file and send the second file to the server and work with this variable from the file there.
How to do it?
sh-shnik is transferred in this way:

sshpass -p $PASS ssh $USR@$IP -p $PORT '/opt/deploy.sh'

And accordingly the call line looks like this:
./install-to-host.sh -u root -p test -mip 192.168.4.95 -nn master-1 -port 8888

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sergey, 2019-09-07
kuzmin @sergueik

pass as normal arguments
e.g.

ssh [email protected]$IP '/bin/sh /opt/deploy_with_args.sh A B'
A
B

where/opt/deploy_with_args.sh
#!/bin/sh
echo $1
echo $2
exit 0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question