I am trying to run a series of commands on a remote server from a jenkins machine. Those commands do below stuff
- Create a directory on remote server
- Copy some files from remote server into that directory
I have created below script,
servername=<remote server ip>
sshuserconnect() {
echo `/usr/bin/sshpass -p passwd ssh -o ConnectTimeout=5 -o UserKnownHostsFile=knownhosts -o StrictHostKeyChecking=no $*`
}
sshuserconnect user@$servername << ENDOFSSH
sqlplus -s /nolog << EOF > /home/user/output.txt
connect user/pwd@$servername:<port>/<DB schema>
select column1||','||value from table where column1 like 'param1';
EOF
version=`grep version /home/user/output.txt | cut -f 2 -d ","`
mkdir /home/user/${version}
ENDOFSSH
Script fails with below error,
grep: output.txt: No such file or directory
Pseudo-terminal will not be allocated because stdin is not a terminal.
After some debugging I found out that script fails only for grep command. Assigning grep output to version variable fails.
I have tried lot of options and I am not if this is the correct way. Can anyone help me to resolve this?