Contents
What are the variables in the SSH script?
That script happens to contain $2 and $logfilepattern (the text between single quotes is passed literally as an argument to the ssh command, so it’s a code snippet to execute on the other side). These refer to variables of the shell running on the remove side. Actually, you’re running two shells on the remote side, but not usefully so.
How is shell pass variable passed to SSH?
Above, we’re passing the content of the $parameter bash shell variable as the LC_parameter environment variable to ssh. ssh sends that over to sshd, which if it accepts it, passes it as an environment variable to the login shell of the user which then passes it to that csh command (which can then expand it).
Can you pass a script string to SSH?
SSH always invokes a shell; you can pass it multiple arguments but they’re just joined with spaces in between. The shell on the remote side executes bash -c \\ #script string starts here cd $2 …
Do you explicitly invoke the shell in SSH?
It’s better to explicitly invoke the shell to avoid surprises ( ssh host csh also means a tty is not requested so you don’t need -T ). Note the $LC_parameter:q syntax, which is the csh way to pass the content of a variable verbatim, not “$LC_parameter” which doesn’t work if the variable contains newline characters.
What is the first line in the bash script?
The first line invokes bash with two arguments: -c and a single space. This invokes a shell to do nothing. The rest of the remote command is executed in the shell invoked by SSH.
What happens if a file name is not quoted in Bash?
If that file doesn’t exist (as is the case for you), it will report an error. Since * is not quoted this time, it triggers another special feature of the shell called globbing or filename generation or filename expansion. The shell tries to expand the word that contains that * character to the list of file names that match the pattern.