fork and exec

I need to ssh to a remote server and run my script there. This is my script.

$ssh = "ssh username@host";
$cmd = "$ssh 'cd <my dir> && < sudo Run_exe>'";

my $pid = fork;
if ($pid == 0){
exec $cmd;
}

When I run this I get:
pccons_getchar: got r == 0

assuming perl........

not sure if this is the source of your problem, but the @ symbol is being interpolated as an array because you have it inside a double-quoted string, use single-quotes:

$ssh = 'ssh username@host';

also, when you use exec in perl it does not return back to the perl script, although I am not sure what happens when you run it in a forked process. Try system() or qx//. qx// returns process output back, system() does not. Look them up in the perl documentation.

Next time put Perl in your subject line if that is what you are using.

fork and exec : Perl