Scp files to another server help

Discussion in 'Perl Misc' started by JennAshton, Dec 9, 2003.

  1. JennAshton

    JennAshton Guest

    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;
    JennAshton, Dec 9, 2003
    #1
    1. Advertising

  2. (JennAshton) wrote in
    news::

    > 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

    Remove dashes for address
    Spam bait: mailto:
    A. Sinan Unur, Dec 9, 2003
    #2
    1. Advertising

  3. On 8 Dec 2003 18:05:19 -0800
    (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
    James Willmore, Dec 9, 2003
    #3
  4. JennAshton

    Jim Mozley Guest

    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
    Jim Mozley, Dec 9, 2003
    #4
  5. JennAshton

    lostriver Guest

    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
    lostriver, Dec 9, 2003
    #5
  6. JennAshton

    Tintin Guest

    "JennAshton" <> wrote in message
    news:...
    > 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
    Tintin, Dec 10, 2003
    #6
  7. JennAshton

    JoelAshton Guest

    "Tintin" <> wrote in message news:<br68g0$28enps$-berlin.de>...
    > "JennAshton" <> wrote in message
    > news:...
    > > 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?
    JoelAshton, Dec 12, 2003
    #7
  8. JennAshton

    Mike Hunter Guest

    [OT] Re: Scp files to another server help

    On 12 Dec 2003 13:41:46 -0800, JoelAshton wrote:
    > "Tintin" <> wrote in message news:<br68g0$28enps$-berlin.de>...
    > > "JennAshton" <> wrote in message
    > > news:...
    > > > 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
    Mike Hunter, Dec 13, 2003
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Xavier

    Classes SSH-SCP for Java

    Xavier, Oct 27, 2004, in forum: Java
    Replies:
    9
    Views:
    10,129
    Michael Borgwardt
    Nov 5, 2004
  2. Tim Golden
    Replies:
    0
    Views:
    524
    Tim Golden
    Nov 7, 2005
  3. krabhi
    Replies:
    1
    Views:
    9,272
    Marco Meschieri
    Aug 9, 2006
  4. Une Bévue
    Replies:
    0
    Views:
    371
    Une Bévue
    Jul 22, 2008
  5. Mike
    Replies:
    15
    Views:
    1,952
    Roedy Green
    Feb 9, 2012
Loading...

Share This Page