I have a perl script that runs this command:
my $sshstart = `ssh username\@server "cd "$(dirname "$(find /OnSight/jetplan -type f -name AddAlias.pl)")" "`;
which works when I run the ssh part in the actual terminal but ran in a script returns this:
syntax error at line 1 : `)' unexpected
I've removed the "" everywhere (except the ssh command "" because it has to have that to run any commands once I get into the server) which it can still run just in the terminal.
I've removed all the ()
I've added () to the front and back, or doing only one on each side and still no luck.
Is it because its within the ssh quotes ""?
If so what syntax do I use?
CodePudding user response:
You need to use single quote and escape $
:
my $sshstart = `ssh username\@server 'cd "\$(dirname "\$(find /OnSight/jetplan -type f -name AddAlias.pl)")"'`;