views:

46

answers:

1

Hello,

I have a script in remote host which I run as ./test /a/b/c/f and it runs perfectly fine on the maching.

Now I am on host machine, I run the same script as ssh root@dst "./test /a/b/c/f" and this too runs fine.

But from my perl script I execute it using backticks as

$file = "/a/b/c/f";
`ssh root\@dst "./test $file"`;

or

system("ssh root\@dst \"./test $file\" ");

it says bash:./test no such file or directory.

I tried escaping $file with single \ and \. even that does not work. Any idea how to solve this,

Thanks.

+3  A: 

Have you tried using an absolute path instead of one based on ./ ? It'll probably solve this problem, and it's safer in general (especially when connecting as root) than depending on whatever sets the cwd (probably bash based on history) to set it the same way every time.

metamatt
Hey thanks so much. That worked :)
pythonperl