idleonbench idleonbench - 11 months ago 33
Perl Question

Errant error output behavior with perl execute bash scripts on a remote machine

I have this line in my perl script that sshes into a remote machine and execute a bash script:

system("ssh -t remotemachine /dir/dir/bashscript");

In my bash script, I used exit code 2
some commands 2 >> error.txt
to capture any errors that I may encounter and I want this error.txt to be written in the same folder where the bash script is stored.

My problem is when I ssh into the machine and run the program from the terminal, the error can be captured and written in error.txt but if I run the program from my perl, the program is able to run but the error is not captured.

Any suggestions?


Use the full path for the capture file.

some commands 2 >> /dir/dir/error.txt

Otherwise the file will be created in the users $HOME if it exists.