Run multiple commands in ssh

Hi All,

I have the below requirement.
I want to copy the local file to remote after that i need to run the local script on a remote machine.When i use two ssh commnds i can achieve this. But i want to achieve this using one ssh command.

Below command to copy the local file to remote

ssh -q user@host cat < $datadir/test.txt ">" /home_dir/test.txt

below command i used to run local script on remote.

ssh -q user@host "ksh -s" < $scriptdir/test.sh "$omsDir" 

But when i try to combine the two commads its not working properly.
I tried the below code

ssh -q user@host  cat < $datadir/test.txt ">" /home_dir/test.txt ; `ksh -s` < $scriptdir/test.sh "$omsDir" 

when i tried with the above code i guess script is not working in local i.e it tries to search for for the file test.txt to copy in remote instead of local same way test.sh is also searching in remote.
Please help me in this.

ssh -q user@host << ! > /home_dir/test.txt
cat < $datadir/test.txt
ksh -s
$scriptdir/test.sh "$omsDir"
exit
!
1 Like

The problem is that ssh/sshd take only one stdin channel (unless they provide special options that I haven't discovered yet).
I cannot see that the previous post solves it.