Hello Monks, Was wondering if someone could give me ideas as to how to access a remote server and move files around as per some criteria specified.I figure that i have to use something like file::remote.pm but can't find any good tutorials for that.I'm a beginner.

I would love to hear any other ways of doing this.My perl script cannot reside on the server since its used for multiple projects but the reqmnt is that i need to access move and copy certain files in a dump folder.

Thanks
Smanicka
--------------------------------------------------------------------------
Dec 05 2008
Here is an update on what I have done so far.
This is the code to get the list of files in my directory H:\What_to_do and to look up what to do with the m based on the information specified by the filename.

The file names are given as SYSX%RPT%JOB%TIMEDATEstamp.txt.
The Database is an access database that i am using.It looks like this:

+--------+-------------+---------+------+------+
|Sys_Acc | Report_name |Job_name | Dump |Print |
+--------+-------------+---------+------+------+
|SYSX    |  abc        | 123a    | yes  |  no  |
+--------+-------------+---------+------+------+
|SYSY    |  ade        | 783a    | no   |  yes |
+--------+-------------+---------+------+------+ 

and some same file names are here:
SYSX%abc%123a%12.03.2008.01.32.22.txt
SYSX%abc%123a%12.03.2008.01.32.22.txt
#!usr/bin/perl -w use DBI; use File::Copy; @files=<H:/what_to_do/*>; print "+---------------------------------------------+\n"; print "| Here are the list of files in the directory |\n"; print "+---------------------------------------------+\n\n"; foreach my $file (@files){ my @arr=split(/\//,$file); print "\n"; my @field=split(/%/,$arr[2]); print $arr[2]."\n\n................................................... +.......\n"; my @arr1=split(/\./,$field[3]); pop(@arr1); my $sec=pop(@arr1); my $min=pop(@arr1); my $hr=pop(@arr1); my $date_string=join('-',@arr1); my $sysacc=$field[0]; my $rid=$field[2]; my $jid=$field[1]; my $time=$hr.":".$min.":".$sec; #print "System:\t\t $sysacc \nreport id:\t$rid \njob id:\t\t$jid\ndate + stamp:\t$date_string\ntime :\t\t$hr:$min:$sec \n"; #print "============================================================== +=\n"; my $oldloc=$file; $dbh = DBI->connect('dbi:ODBC:driver=microsoft access driver (*.mdb);d +bq=C:\Documents and Settings\smanicka\Desktop\public_html\lookup_test +.mdb') or die "Sorry,Cant connect\n $DBI::errstr \n"; my $query= "select * from lookup where Sys_Acc=\'$sysacc\' AND Job_nam +e=\'$jid\' AND Report_name=\'$rid\'"; my $sth=$dbh->prepare($query); $sth->execute(); my $status=0; my @stash; while($arr_ref=$sth->fetchrow_array()){ #$status=1; push @stash,[@$array_ref]; } foreach $array_ref(@stash){ print "ROw: @$array_ref \n"; } #if($status==0){ #print " not found"; #} #else{ #print "found";} ## where Sys_Acc=\'$sysacc\'& Job_name=\'$jid\' & Report_name=\'$rid\' #$newloc="h:/newtest/$sysacc/$arr[2]"; #move($oldloc,$newloc)or die "fail to move"; }


Right now I am messing about on my local machine witht he file movement.
The problem is , the $sth->fetchrow_array() doesnt seem to ever return a value. Could anyone clarify this for me? Thank you Monks.
Smanicka
PS. I'm sorry if i am sending this info to anyone's account etc, I m still trying to figure out how to navigate around perlmonk.com and am not sure I am doin things right

In reply to need to access a remote server to move the files around in a set folder there by smanicka

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.