Scp files to another server help

J

JennAshton

Hi,

I wrote a simple scp script from my server to pacman server which
copies all jpg files to /jennash/ directory.

Now, I need help with this script. I would like it to pull not just
*.jpg files but other file types as well. Also, is it possible to pull
only files that is 3 minutes old? Please help.

Thanks!

JennAsh

#!/usr/bin/perl

system('scp /export/www/docs/*.jpg pacman:/export/www/jennash/');

exit;
 
A

A. Sinan Unur

(e-mail address removed) (JennAshton) wrote in
Hi,

I wrote a simple scp script from my server to pacman server which
copies all jpg files to /jennash/ directory. ....
#!/usr/bin/perl

system('scp /export/www/docs/*.jpg pacman:/export/www/jennash/');

exit;

Well, this is a Perl script in a very loose sense of the word.

Now, I need help with this script. I would like it to pull not just
*.jpg files but other file types as well.

Definitely doable .. just change the extension.
Also, is it possible to pull only files that is 3 minutes old?

perldoc -f stat


Please help.
 
J

James Willmore

On 8 Dec 2003 18:05:19 -0800
I wrote a simple scp script from my server to pacman server which
copies all jpg files to /jennash/ directory.

Now, I need help with this script. I would like it to pull not just
*.jpg files but other file types as well. Also, is it possible to
pull only files that is 3 minutes old? Please help.

Thanks!

JennAsh

#!/usr/bin/perl

system('scp /export/www/docs/*.jpg pacman:/export/www/jennash/');

exit;

You could check out the Net::SCP and File::Find modules. What you
have written could have been done in *any* *NIX shell - for as little
Perl you have in it.

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
You should never wear your best trousers when you go out to fight
for freedom and liberty. -- Henrik Ibsen
 
J

Jim Mozley

JennAshton wrote:

I wrote a simple scp script from my server to pacman server which
copies all jpg files to /jennash/ directory.

This answer is not perl related directly, but I moved from using scp to
rsync for this type of thing. The perl bit is that once files were
transferred I then needed to do other tasks (e.g. sighup a daemon) so I
used the perl script which did the rsync to perform other tasks.

Jim
 
L

lostriver

JennAshton wrote:



This answer is not perl related directly, but I moved from using scp to
rsync for this type of thing. The perl bit is that once files were
transferred I then needed to do other tasks (e.g. sighup a daemon) so I
used the perl script which did the rsync to perform other tasks.

Jim

Try Net::SFTP. Gives you whole lot more of control - you can verify sizes
after transfer of each file, set timeouts for login and per file transfer, etc
 
T

Tintin

JennAshton said:
Hi,

I wrote a simple scp script from my server to pacman server which
copies all jpg files to /jennash/ directory.

Now, I need help with this script. I would like it to pull not just
*.jpg files but other file types as well. Also, is it possible to pull
only files that is 3 minutes old? Please help.

Thanks!

JennAsh

#!/usr/bin/perl

system('scp /export/www/docs/*.jpg pacman:/export/www/jennash/');

exit;

And the relevance to Perl is???

Here's a shell script to do it:

#!/bin/sh
scp `find /export/www/docs -type f -mmin 3` pacman:/export/www/jennash
 
J

JoelAshton

Tintin said:
And the relevance to Perl is???

Here's a shell script to do it:

#!/bin/sh
scp `find /export/www/docs -type f -mmin 3` pacman:/export/www/jennash


Well, seeing your shell script I was able to come up with this
rsync -rt -e /usr/local/bin/ssh /htodcs/www/my_folder/
pacman:/htdocs/www/remote_folder

The above script allows me to execute via command line in Unix.
However, when I saved the script has shell script and tried to
executed via browser it didn't work.

The page displays:

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these two things: #1) Respect
the privacy of others. #2) Think before you type. Password:


Not sure why it is displaying since the sys-admin open up ssh
connection and a key has been established in my local directory in the
remote server.

Can anyone advise?
 
M

Mike Hunter

Well, seeing your shell script I was able to come up with this
rsync -rt -e /usr/local/bin/ssh /htodcs/www/my_folder/
pacman:/htdocs/www/remote_folder

The above script allows me to execute via command line in Unix.
However, when I saved the script has shell script and tried to
executed via browser it didn't work.

The page displays:

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these two things: #1) Respect
the privacy of others. #2) Think before you type. Password:


Not sure why it is displaying since the sys-admin open up ssh
connection and a key has been established in my local directory in the
remote server.

Can anyone advise?

If you run it as a CGI, you'll be running it as a different user. I don't
know how your web server is set up, so I can't tell you how to fix it, but
you somehow need to get the script to run as the appropriate user, perhaps
using the "setuid" bit for the executable permission.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top