1
I have a variable setup like this:
SSH_EXEC="ssh -X -o ControlPath=~/.ssh/master-$$ -o ControlPersist=60"
The parameter in question is the -X
, because if I then call this command within my local script
$SSH_EXEC user@server "./server_script.sh $aFile"
which in a nutshell does the following:
if [ -e /path/"$1".name ] || [ -e /path/"$1" ]
then
do something
else
error
echo "/path/"$1".name"
exit
fi
Everything works! But if I replace -X
with -t
, my server_script
fails to the else
on the test. I'd prefer not use x11, but I'm not sure what the difference is that is causing it to fail in one instance, and pass in the other.
EDIT
So I just did more troubleshooting and decided to echo the value of /path/$1.name
on the server and it is garbled junk. If my $aFile
name happened to be hello.name
the result of the echo shows .nameello
and also rids the beginning of the path when I use -t
in place of -X
.
What could be causing the corruption of my variables?
You aren't using X11. In one case you enable X11 forwarding, in the other you force a pseudo-tty to be created. Also, your code "in a nutshell" doesn't contain enough (not even the echo) to tell what the problem might be. – Hasturkun – 2013-06-13T15:08:31.550
@Hasturkun I've modified my above example a little more. What I have "in a nutshell" is where my code fails. It's right at the beginning of a long server script. – hax0r_n_code – 2013-06-13T15:12:41.410
It's sort of a silly suggestion, but what happens if you pipe the output from your ssh command through
xxd
or similar? – Hasturkun – 2013-06-13T15:17:15.050@Hasturkun not a silly question! I don't know what
xxd
is, could you elaborate? – hax0r_n_code – 2013-06-13T15:19:35.203Hex dump. I'm guessing there are control characters in your output, eg. a
^H
(backspace) would delete the characters before it in shell output. Would be visible in a hex dump. In this case, my psychic powers tell me it's a^M
(Carriage return) at the end of$aFile
– Hasturkun – 2013-06-13T15:21:11.173Do you think that doing a
-o SendEnv $aFile
would ensure the variable is properly transferred as an argument to the server script? – hax0r_n_code – 2013-06-13T15:24:05.847let us continue this discussion in chat
– Hasturkun – 2013-06-13T15:25:16.107Not sure why people are voting to close the thread since it clearly relates to programming? – hax0r_n_code – 2013-06-13T16:16:07.797