I am trying to do a ssh for performing a set of actions.
Find it below:
I need to put the user/ kernel/ DISTRO variables before I complete this operation.
what I observed is when ever I put a `command` in those quotes, it performs thta action in local system rather than remote one.
#!/bin/bash
BUILDDIR=$PWD
ssh sna4 "
echo $pwd;
mkdir testing_dir;
cd testing_dir;
echo $HOSTNAME@$PWD;
pwd;
uname -n;
echo $BUILDDIR;
whoami ;
uname -n;
x=`uname -n`
echo $x
echo "jfhjfhhfjkjfh" > xx;
cat xx
"
If I want to store a data like that how can do using just ssh.
Consider using ' quotes around the commands to be executed on the remote host instead of ". This will mean that backquotes will be handled remotely. However it will also mean that variable expansions (e.g. $HOSTNAME) will also be handled remotely.
if used with ssh' commands ', the MACROS defined in the script file do not get carry forwarded after ssh. I mean I am not able to use those MACROS in the ssh commands.