How can I make cat someFile | ssh someHost work when someFile is not a bash script? I want to remotely execute a perl script but I get a bunch of syntax errors from bash when I try the cat | ssh command.
|
|
|
If you want to push the Perl script through the SSH connection, you'll have to run the Perl interpreter on the remote end. It'll read the script from stdin:
In the case of Perl, it should even read the command line switches (except If you want to give command line arguments to the Perl interpreter, you can
just add them to the command line after So, here
Note that doing just |
|||||||||||||
|
|
You don't tell us what someFile is supposed to contain. Assuming its content is supposed to be fed to your perl script, what you should do is:
Or better:
|
|||||
|
|
in ordred to => Write local output into remote file: You just installed the apache on your $myhost. Now you want to test it. You can echo the test string into file, only this time the file is in remote htdocs root: echo "It works" | ssh [email protected] 'cat >> /usr/local/apache/htdocs/it_works.html' Open remote file with less or cat: With cat: ssh [email protected] "cat /usr/local/apache/htdocs/it_works.html" With less: ssh [email protected] "less /usr/local/apache/htdocs/it_works.html" Grep remote files: With pipe: ssh [email protected] "cat /usr/local/apache/htdocs/it_works.html" | grep "works" Just remote grep: ssh [email protected] "grep works /usr/local/apache/htdocs/it_works.html" Watching remote logs with tail: This way you can watch the access to apache server in real-time: ssh [email protected] "tail -f /etc/httpd/logfiles/access_log" The source for this answer is here. I hope it helped you. |
|||||||||||||||||
|