mercuryshipz has asked for the wisdom of the Perl Monks concerning the following question:

I want to copy a script to a remote machine, execute it and return the result, after retuning the result the script has to be deleted from that remote server.
for eg:
i want to run my file parser script and run it against the log file sitting on the remote machine and get the result, and delete my script on the remote server.
i tried to use the scp command, like:
scp login:password@host:file.txt file_backup.txt
i wanna know where to give the path of the log file on remote server in this line. and can i give this line inside my script itself.

Replies are listed 'Best First'.
Re: scp perl
by halley (Prior) on Feb 05, 2008 at 16:48 UTC
    This seems to have nothing to do with perl... but I'll bite.
    system('scp login:password@host:path/to/file.txt file_backup.txt'); if (-f 'file_backup.txt') { system('ssh login:password@host rm path/to/file.txt'); }
    More safeguards are necessary here, and I shudder to see a password in plaintext. Learn to use ssh's authorized_keys file at the minimum. Reading all of ssh's manpage until enlightenment comes is better.

    [ e d @ h a l l e y . c c ]

      One perl related safe-guard I'd recommend is to use the multi-argument form of system:

      system('scp', "login:password@host:path/to/file.txt", "file_backup.txt");

      Also, I'd second the use of authorized_keys. Not only is it more convenient, but it centralizes the management of your security which very helpful.