Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Scp files to another server help

Reply
Thread Tools

Scp files to another server help

 
 
JennAshton
Guest
Posts: n/a
 
      12-09-2003
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;
 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      12-09-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (JennAshton) wrote in
news:(E-Mail Removed) om:

> 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.


--
A. Sinan Unur
(E-Mail Removed)
Remove dashes for address
Spam bait: (E-Mail Removed)
 
Reply With Quote
 
 
 
 
James Willmore
Guest
Posts: n/a
 
      12-09-2003
On 8 Dec 2003 18:05:19 -0800
(E-Mail Removed) (JennAshton) wrote:
> 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
 
Reply With Quote
 
Jim Mozley
Guest
Posts: n/a
 
      12-09-2003
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
 
Reply With Quote
 
lostriver
Guest
Posts: n/a
 
      12-09-2003
On Tue, 09 Dec 2003 10:16:25 +0000, Jim Mozley wrote:
> 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


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



--
..signature: No such file or directory
 
Reply With Quote
 
Tintin
Guest
Posts: n/a
 
      12-10-2003

"JennAshton" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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


 
Reply With Quote
 
JoelAshton
Guest
Posts: n/a
 
      12-12-2003
"Tintin" <(E-Mail Removed)> wrote in message news:<br68g0$28enps$(E-Mail Removed)-berlin.de>...
> "JennAshton" <> wrote in message
> news:(E-Mail Removed) om...
> > 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



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?
 
Reply With Quote
 
Mike Hunter
Guest
Posts: n/a
 
      12-13-2003
On 12 Dec 2003 13:41:46 -0800, JoelAshton wrote:
> "Tintin" <(E-Mail Removed)> wrote in message news:<br68g0$28enps$(E-Mail Removed)-berlin.de>...
> > "JennAshton" <> wrote in message
> > news:(E-Mail Removed) om...
> > > 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

>
>
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to transfer files through SCP protocol in between two network connections in java kittu2468 General Computer Support 0 07-29-2012 01:36 PM
How do I scp extremely large files Mike Java 15 02-09-2012 06:37 AM
SCP did not finish successfully () (Net::SCP::Error Une Bévue Ruby 0 07-22-2008 04:26 PM
Maven using ANT plugin for SCP task : Embedded error: Could not create task or type of type: scp. krabhi Java 1 08-09-2006 04:19 PM
RE: connect to a remote web server & upload data from Python usingsshand scp Tim Golden Python 0 11-07-2005 08:54 AM



Advertisments