Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

scp perl

by mercuryshipz (Acolyte)
on Feb 05, 2008 at 15:57 UTC ( [id://666328]=perlquestion: print w/replies, xml ) Need Help??

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

hi,
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.
thanks,
Mercury.

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://666328]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (1)
As of 2024-04-25 01:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found