<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Help perl scp script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126213#M31279</link>
    <description>All,&lt;BR /&gt;&lt;BR /&gt;    I create a perl script that tar all files in directory.&lt;BR /&gt;&lt;BR /&gt;Dev Server:&lt;BR /&gt;/dir/dir1/upload&lt;BR /&gt;/dir/dir2/upload&lt;BR /&gt;/dir/dir3/upload&lt;BR /&gt;&lt;BR /&gt;No problem creating tar file in all directory above. &lt;BR /&gt;&lt;BR /&gt;I want to scp the tar file from /dir/dir/upload&lt;BR /&gt;to PROD SRV. /dir/dir1, etc&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;my @upload_dir = ('/dir/dir1/upload',&lt;BR /&gt;                  '/dir/dir2/upload'&lt;BR /&gt;                 );&lt;BR /&gt;&lt;BR /&gt;my @upload_server = ('prod_srv');&lt;BR /&gt;&lt;BR /&gt;foreach my $dir (@upload_dir)&lt;BR /&gt;{&lt;BR /&gt;    chdir ($dir);&lt;BR /&gt;&lt;BR /&gt;   system("tar cvf upload.tar *");&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I appreciate all help.&lt;BR /&gt;&lt;BR /&gt;JC</description>
    <pubDate>Tue, 08 Jan 2008 21:35:36 GMT</pubDate>
    <dc:creator>Junior C.</dc:creator>
    <dc:date>2008-01-08T21:35:36Z</dc:date>
    <item>
      <title>Help perl scp script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126213#M31279</link>
      <description>All,&lt;BR /&gt;&lt;BR /&gt;    I create a perl script that tar all files in directory.&lt;BR /&gt;&lt;BR /&gt;Dev Server:&lt;BR /&gt;/dir/dir1/upload&lt;BR /&gt;/dir/dir2/upload&lt;BR /&gt;/dir/dir3/upload&lt;BR /&gt;&lt;BR /&gt;No problem creating tar file in all directory above. &lt;BR /&gt;&lt;BR /&gt;I want to scp the tar file from /dir/dir/upload&lt;BR /&gt;to PROD SRV. /dir/dir1, etc&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;my @upload_dir = ('/dir/dir1/upload',&lt;BR /&gt;                  '/dir/dir2/upload'&lt;BR /&gt;                 );&lt;BR /&gt;&lt;BR /&gt;my @upload_server = ('prod_srv');&lt;BR /&gt;&lt;BR /&gt;foreach my $dir (@upload_dir)&lt;BR /&gt;{&lt;BR /&gt;    chdir ($dir);&lt;BR /&gt;&lt;BR /&gt;   system("tar cvf upload.tar *");&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I appreciate all help.&lt;BR /&gt;&lt;BR /&gt;JC</description>
      <pubDate>Tue, 08 Jan 2008 21:35:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126213#M31279</guid>
      <dc:creator>Junior C.</dc:creator>
      <dc:date>2008-01-08T21:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: Help perl scp script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126214#M31280</link>
      <description>Why drag perl into it, when a simple shell&lt;BR /&gt;script could do the job?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;  system("tar cvf upload.tar *");&lt;BR /&gt;&lt;BR /&gt;I'd use "tar cvf upload.tar .".  For the&lt;BR /&gt;reason, see, for example:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1191368" target="_blank"&gt;http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1191368&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;If you insist on using perl, and you do the&lt;BR /&gt;"tar" using system(), then why not use&lt;BR /&gt;system() again to do the scp operation?  If&lt;BR /&gt;you use a simple shell script, why not just&lt;BR /&gt;put the scp command into it?</description>
      <pubDate>Wed, 09 Jan 2008 03:19:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126214#M31280</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-01-09T03:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Help perl scp script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126215#M31281</link>
      <description>Steven,&lt;BR /&gt;&lt;BR /&gt;  Shell or perl &lt;BR /&gt;&lt;BR /&gt;I want to scp tar file from &lt;BR /&gt;&lt;BR /&gt;SERVER_A           SERVER_B&lt;BR /&gt;/abc/dir1/upload   /abc/dir1&lt;BR /&gt;/efg/dir2/upload   /efg/dir2&lt;BR /&gt;/hij/dir3/upload   /hij/dir3&lt;BR /&gt;/xzy/dir4/upload   /xyz/dir4&lt;BR /&gt;&lt;BR /&gt;JC</description>
      <pubDate>Wed, 09 Jan 2008 03:45:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126215#M31281</guid>
      <dc:creator>Junior C.</dc:creator>
      <dc:date>2008-01-09T03:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: Help perl scp script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126216#M31282</link>
      <description>&amp;gt; I want to scp tar file [...]&lt;BR /&gt;&lt;BR /&gt;Ok.  Go ahead.  "man scp"?  "scp -h"?&lt;BR /&gt;&lt;BR /&gt;Do you have ssh working between these two&lt;BR /&gt;systems?&lt;BR /&gt;&lt;BR /&gt;Is the problem how to put an scp command&lt;BR /&gt;into a script, or how to make an scp command&lt;BR /&gt;work, or what?</description>
      <pubDate>Wed, 09 Jan 2008 03:52:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126216#M31282</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-01-09T03:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: Help perl scp script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126217#M31283</link>
      <description>Steven.&lt;BR /&gt;&lt;BR /&gt;OK, lets start from the top.&lt;BR /&gt;I know how to scp a file from severA to severB&lt;BR /&gt;&lt;BR /&gt;I need help in creating a script to scp tar files from &lt;BR /&gt;&lt;BR /&gt;SERVER_A &lt;BR /&gt;/abc/dir1/XYZ/upload/upload.tar &lt;BR /&gt;/efg/dir2/DIR2/upload/upload.tar  &lt;BR /&gt;/hij/dir3/ABC/upload/upload.tar  &lt;BR /&gt;/xzy/dir4/upload/upload.tar &lt;BR /&gt;etc..&lt;BR /&gt;etc..&lt;BR /&gt;etc..&lt;BR /&gt;etc.. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SERVER_B&lt;BR /&gt;/abc/dir1/XYZ&lt;BR /&gt;/efg/dir2/DIR2&lt;BR /&gt;/hij/dir3/ABC&lt;BR /&gt;/xyz/dir4&lt;BR /&gt;etc...&lt;BR /&gt;etc.&lt;BR /&gt;&lt;BR /&gt;SERVER_C&lt;BR /&gt;/abc/dir1/XYZ&lt;BR /&gt;/efg/dir2/DIR2&lt;BR /&gt;/hij/dir3/ABC&lt;BR /&gt;/xyz/dir4&lt;BR /&gt;etc...&lt;BR /&gt;etc.&lt;BR /&gt;&lt;BR /&gt;SERVER_A &lt;BR /&gt;scp /abc/dir1/XYZ/upload/upload.tar SERVER_B:/abc/dir1/XYZ&lt;BR /&gt;&lt;BR /&gt;SERVER_A &lt;BR /&gt;scp /abc/dir1/XYZ/upload/upload.tar SERVER_C:/abc/dir1/XYZ&lt;BR /&gt;&lt;BR /&gt;NOTE: That upload directory is just a holding area on SERVER_A  I do not have a /abc/dir1/XYZ/upload/ on SERVER_B and SERVER_C&lt;BR /&gt;&lt;BR /&gt;JC&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Jan 2008 14:58:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126217#M31283</guid>
      <dc:creator>Junior C.</dc:creator>
      <dc:date>2008-01-09T14:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help perl scp script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126218#M31284</link>
      <description>OK, then.&lt;BR /&gt;You will need to copy your public ssh key to allow passwordless login to server_a and server_b.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Then after you created the tarball, test if the directory structure exists on the destination server. If not create it, otherwise just copy the file to the destination directory:&lt;BR /&gt;destdir="/abc/dir1/XYZ"&lt;BR /&gt;for i in a b; do &lt;BR /&gt; ssh server_$i test -d $destdir &lt;BR /&gt; if [ $? -ne 0 ]; then &lt;BR /&gt; ssh server_${i} mkdir -p $destdir&lt;BR /&gt; scp &lt;SOURCE_FILE&gt; server_${i}:$destdir&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SOURCE_FILE&gt;</description>
      <pubDate>Wed, 09 Jan 2008 16:02:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126218#M31284</guid>
      <dc:creator>Alexander Chuzhoy</dc:creator>
      <dc:date>2008-01-09T16:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Help perl scp script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126219#M31285</link>
      <description>Alexander,&lt;BR /&gt;&lt;BR /&gt;Thanks for the reply.&lt;BR /&gt;&lt;BR /&gt;Following are my directory structure.&lt;BR /&gt;&lt;BR /&gt;SERVER_A  Example:&lt;BR /&gt;/usr/bin/test/upload&lt;BR /&gt;/etc/bin/home/upload&lt;BR /&gt;/sbin/home/help/upload&lt;BR /&gt;/var/sbin/home/bin/upload&lt;BR /&gt;..&lt;BR /&gt;..&lt;BR /&gt;/directory/ten/upload&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In my perl script I loop/cd to /upload dir and tar all files in the directory, creating upload.tar file.&lt;BR /&gt;&lt;BR /&gt;NEXT&lt;BR /&gt;&lt;BR /&gt;After the upload.tar file is created on SERVER_A in /sbin/home/help/upload/upload.tar&lt;BR /&gt;&lt;BR /&gt;I wan't scp the upload.tar file to SERVER_B and SERVER_C&lt;BR /&gt;&lt;BR /&gt;scp /sbin/home/help/upload/upload.tar             SERVER_B:/sbin/home/help&lt;BR /&gt;&lt;BR /&gt;scp /sbin/home/help/upload/upload.tar             SERVER_C:/sbin/home/help&lt;BR /&gt;&lt;BR /&gt;THEN&lt;BR /&gt;     create upload.tar file on SERVER_A in directory /var/sbin/home/bin/upload/upload.tar &lt;BR /&gt;&lt;BR /&gt;scp /var/sbin/home/bin/upload/upload.tar          SERVER_B:/var/sbin/home/bin/&lt;BR /&gt;&lt;BR /&gt;scp /var/sbin/home/bin/upload/upload.tar          SERVER_C:/var/sbin/home/bin/&lt;BR /&gt;&lt;BR /&gt;etc,&lt;BR /&gt;etc,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-JC&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Jan 2008 20:29:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126219#M31285</guid>
      <dc:creator>Junior C.</dc:creator>
      <dc:date>2008-01-09T20:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help perl scp script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126220#M31286</link>
      <description>&lt;!--!*#--&gt;You can omit the temporal local creation of the tar files if you are short on disk space&lt;BR /&gt;by directly piping into ssh.&lt;BR /&gt;Here is a code snippet of one way how this could be done.&lt;BR /&gt;This requires a previously created and distributed RSA key (i.e. the arg to -i).&lt;BR /&gt;Please, adapt to your users, hosts, file paths etc.&lt;BR /&gt;&lt;BR /&gt;my $ruser = 'someone';&lt;BR /&gt;my $rhost = '123.123.123.123';&lt;BR /&gt;my $ldir  = '/etc';&lt;BR /&gt;my $rdir  = '/var/tmp/etc.bak';&lt;BR /&gt;my $rsa_key = "$ENV{HOME}/.ssh/id_rsa";&lt;BR /&gt;my $pid = open PSSH, '|-';&lt;BR /&gt;die "cannot open pipe\n" unless defined $pid;&lt;BR /&gt;if ($pid) {&lt;BR /&gt;    chdir $ldir;&lt;BR /&gt;    select((select(PSSH), $|=1)[0]);&lt;BR /&gt;    print PSSH qx(/bin/tar cf - .);&lt;BR /&gt;} else {&lt;BR /&gt;    exec qw(/usr/bin/ssh -o BatchMode=yes -q -C -T -i),&lt;BR /&gt;            $rsa_key, "$ruser\@$rhost",&lt;BR /&gt;            "mkdir -p $rdir &amp;amp;&amp;amp; cd $rdir &amp;amp;&amp;amp; tar xf -";&lt;BR /&gt;}&lt;BR /&gt;close PSSH;&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Jan 2008 11:10:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126220#M31286</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2008-01-10T11:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: Help perl scp script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126221#M31287</link>
      <description>Ok, hope I understood now. I don't have a linux machine next to me to test the script,but it should be something like the following:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;my $upload="upload";&lt;BR /&gt;my @servers=( "10.10.10.10", "20.20.20.20");&lt;BR /&gt;my @dirs=("/usr/bin/test/","/etc/bin/home/","/sbin/home/help/","/var/sbin/home/bin/");&lt;BR /&gt;&lt;BR /&gt;for my $dir (@dirs) {&lt;BR /&gt;   print "Creating tar for $dir.\n";&lt;BR /&gt;   my $localdir=$dir.$upload;&lt;BR /&gt;   mkdir $localdir unless -d $localdir; &lt;BR /&gt;   chdir $localdir;&lt;BR /&gt;   system "tar cvf upload.tar ./*";&lt;BR /&gt;   for my $server (@servers) {&lt;BR /&gt;       print "Copying the tarball for $dir to $server.\n";&lt;BR /&gt;       system "scp upload.tar $server:$dir";&lt;BR /&gt;     }&lt;BR /&gt;}</description>
      <pubDate>Thu, 10 Jan 2008 18:18:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-perl-scp-script/m-p/4126221#M31287</guid>
      <dc:creator>Alexander Chuzhoy</dc:creator>
      <dc:date>2008-01-10T18:18:37Z</dc:date>
    </item>
  </channel>
</rss>

