Prev: Launch and exit the browser
Next: Huge mailbox split?
From: Radoulov, Dimitre on 16 Jun 2010 05:07 On 15/06/2010 20.31, Atropo wrote: > On Jun 15, 2:08 pm, Atropo<lxvasq...(a)gmail.com> wrote: >> On Jun 15, 11:03 am, "Radoulov, Dimitre"<cichomit...(a)gmail.com> >> wrote: >> >> >> >>> On 15/06/2010 16.52, Atropo wrote: >> >>>> On Jun 15, 10:27 am, "Radoulov, Dimitre"<cichomit...(a)gmail.com> >>>> wrote: >>>>> On 15/06/2010 15.52, Atropo wrote: >> >>>>>> On Jun 14, 4:51 pm, "Radoulov, Dimitre"<cichomit...(a)gmail.com> wrote: >>>>>>> On 14/06/2010 22.47, Radoulov, Dimitre wrote: >> >>>>>>>> On 14/06/2010 15.47, Atropo wrote: >>>>>>>>> Hi all, I'm on solaris 5.10 and trying to get several files from >>>>>>>>> windows server, but with the condition that the files do not have the >>>>>>>>> extension ".par" >> >>>>>>> [...] >> >>>>>>>> perl -MNet::FTP -e' >>>>>>>> ( $host, $user, $pass ) = @ARGV; >>>>>>>> $ftp = Net::FTP->new($host) or die "$@\n"; >>>>>>>> $ftp->login( $user, $pass ) or die $ftp->message; >>>>>>>> $ftp->binary; >>>>>>>> @files = grep !/\.par/, $ftp->ls; >> >>> [...] >> >>>>>> beside this i have a question. in ksh i can get rid off extension >>>>>> using ${file%.*}. how can i use this or something like in perl to >>>>>> avoid getting the files associates to '.par' files. >> >>>>>> in this list i only want to get the last four files >> >>>>>> LOC755225 >>>>>> LOC755225.par >>>>>> LOC705529 >>>>>> LOC705529.par >>>>>> LOC776480 >>>>>> LOC776480.par >>>>>> LOC786253 >>>>>> LOC786219 >>>>>> LOC786210 >>>>>> LOC786202 >> >>>>> You could try something like this: >> >>>>> perl -MNet::FTP -le' >>>>> ( $host, $user, $pass, $dir ) = @ARGV; >>>>> $ftp = Net::FTP->new($host) or die "$@\n"; >>>>> $ftp->login( $user, $pass ) or die $ftp->message; >>>>> $ftp->cwd($dir) or die $ftp->message; >>>>> $ftp->binary; >>>>> /(.*)\.par$/ and $files_ko{$1} = 1 >>>>> or push @files, $_ >>>>> for $ftp->ls; >>>>> $files_ko{$_} or $ftp->get($_) for @files; >>>>> $ftp->quit or die $ftp->message; >>>>> '<host> <user> <user> <dir> >> >>> [...] >> >>>> it runs but it brought >>>> everything. i run as it, 'coz i don't understand any after binary >>>> command [...] >> it works fine, was a typo of mine. but i still >> don't understand >> >> /(.*)\.tag$/ and $files_ko{$1} = 1 >> or push @files, $_ >> for $ftp->ls; >> $files_ko{$_} or $ftp->get($_) for @files; > > > if i want to delete the remote files i have transfer . could I use > @files or do all again like > > > /(.*)\.tag$/ and $files_ko{$1} = 1 > or push @files, $_ > for $ftp->ls; > $files_ko{$_} or $ftp->delete($_) for @files;<= only changed > the "get" for "delete" You could use something like this: perl -MNet::FTP -le' ( $host, $user, $pass, $dir ) = @ARGV; $ftp = Net::FTP->new($host) or die "$@\n"; $ftp->login( $user, $pass ) or die $ftp->message; $ftp->cwd($dir) or die $ftp->message; $ftp->binary; /(.*)\.tag$/ and $files_ko{$1} = 1 or push @files, $_ for $ftp->ls; for (@files) { $ftp->get($_) and $ftp->delete($_) unless exists $files_ko{$_}; } $ftp->quit or die $ftp->message; ' <host> <user> <pass> <dir> Here is the explanation: /(.*)\.tag$/ and $files_ko{$1} = 1 # If a filename matches the # the pattern (.*)\.tag$, # store the string before .tag # in the hash table # (an associative array) # %files_ko as a key, the value # (1) in this case[1] # is irrelevant, # but in Perl it is mandatory (it # could be even undefined, # but it should be explicitly # mentioned (unlike awk). or push @files, $_ # Otherwise, store the filename # in the array @files for $ftp->ls; # The ls method returns the list # with the filenames. for (@files) { $ftp->get($_) and $ftp->delete($_) # Get and delete the file, unless exists $files_ko{$_}; # unless such a key # exists in the hash # %files_ko. HTH Dimitre [1] In my previous code both key and value was used and meaningful.
From: Atropo on 16 Jun 2010 08:52 On Jun 16, 5:07 am, "Radoulov, Dimitre" <cichomit...(a)gmail.com> wrote: > On 15/06/2010 20.31, Atropo wrote: > > > > > On Jun 15, 2:08 pm, Atropo<lxvasq...(a)gmail.com> wrote: > >> On Jun 15, 11:03 am, "Radoulov, Dimitre"<cichomit...(a)gmail.com> > >> wrote: > > >>> On 15/06/2010 16.52, Atropo wrote: > > >>>> On Jun 15, 10:27 am, "Radoulov, Dimitre"<cichomit...(a)gmail.com> > >>>> wrote: > >>>>> On 15/06/2010 15.52, Atropo wrote: > > >>>>>> On Jun 14, 4:51 pm, "Radoulov, Dimitre"<cichomit...(a)gmail.com> wrote: > >>>>>>> On 14/06/2010 22.47, Radoulov, Dimitre wrote: > > >>>>>>>> On 14/06/2010 15.47, Atropo wrote: > >>>>>>>>> Hi all, I'm on solaris 5.10 and trying to get several files from > >>>>>>>>> windows server, but with the condition that the files do not have the > >>>>>>>>> extension ".par" > > >>>>>>> [...] > > >>>>>>>> perl -MNet::FTP -e' > >>>>>>>> ( $host, $user, $pass ) = @ARGV; > >>>>>>>> $ftp = Net::FTP->new($host) or die "$@\n"; > >>>>>>>> $ftp->login( $user, $pass ) or die $ftp->message; > >>>>>>>> $ftp->binary; > >>>>>>>> @files = grep !/\.par/, $ftp->ls; > > >>> [...] > > >>>>>> beside this i have a question. in ksh i can get rid off extension > >>>>>> using ${file%.*}. how can i use this or something like in perl to > >>>>>> avoid getting the files associates to '.par' files. > > >>>>>> in this list i only want to get the last four files > > >>>>>> LOC755225 > >>>>>> LOC755225.par > >>>>>> LOC705529 > >>>>>> LOC705529.par > >>>>>> LOC776480 > >>>>>> LOC776480.par > >>>>>> LOC786253 > >>>>>> LOC786219 > >>>>>> LOC786210 > >>>>>> LOC786202 > > >>>>> You could try something like this: > > >>>>> perl -MNet::FTP -le' > >>>>> ( $host, $user, $pass, $dir ) = @ARGV; > >>>>> $ftp = Net::FTP->new($host) or die "$@\n"; > >>>>> $ftp->login( $user, $pass ) or die $ftp->message; > >>>>> $ftp->cwd($dir) or die $ftp->message; > >>>>> $ftp->binary; > >>>>> /(.*)\.par$/ and $files_ko{$1} = 1 > >>>>> or push @files, $_ > >>>>> for $ftp->ls; > >>>>> $files_ko{$_} or $ftp->get($_) for @files; > >>>>> $ftp->quit or die $ftp->message; > >>>>> '<host> <user> <user> <dir> > > >>> [...] > > >>>> it runs but it brought > >>>> everything. i run as it, 'coz i don't understand any after binary > >>>> command > > [...] > > > > >> it works fine, was a typo of mine. but i still > >> don't understand > > >> /(.*)\.tag$/ and $files_ko{$1} = 1 > >> or push @files, $_ > >> for $ftp->ls; > >> $files_ko{$_} or $ftp->get($_) for @files; > > > if i want to delete the remote files i have transfer . could I use > > @files or do all again like > > > /(.*)\.tag$/ and $files_ko{$1} = 1 > > or push @files, $_ > > for $ftp->ls; > > $files_ko{$_} or $ftp->delete($_) for @files;<= only changed > > the "get" for "delete" > > You could use something like this: > > perl -MNet::FTP -le' > ( $host, $user, $pass, $dir ) = @ARGV; > $ftp = Net::FTP->new($host) or die "$@\n"; > $ftp->login( $user, $pass ) or die $ftp->message; > $ftp->cwd($dir) or die $ftp->message; > $ftp->binary; > /(.*)\.tag$/ and $files_ko{$1} = 1 > or push @files, $_ > for $ftp->ls; > for (@files) { > $ftp->get($_) and $ftp->delete($_) > unless exists $files_ko{$_}; > } > $ftp->quit or die $ftp->message; > ' <host> <user> <pass> <dir> > > Here is the explanation: > > /(.*)\.tag$/ and $files_ko{$1} = 1 # If a filename matches the > # the pattern (.*)\.tag$, > # store the string before .tag > # in the hash table > # (an associative array) > # %files_ko as a key, the value > # (1) in this case[1] > # is irrelevant, > # but in Perl it is mandatory (it > # could be even undefined, > # but it should be explicitly > # mentioned (unlike awk). > or push @files, $_ # Otherwise, store the filename > # in the array @files > for $ftp->ls; # The ls method returns the list > # with the filenames. > > for (@files) { > $ftp->get($_) and $ftp->delete($_) # Get and delete the file, > unless exists $files_ko{$_}; # unless such a key > # exists in the hash > # %files_ko. > > HTH > > Dimitre > > [1] In my previous code both key and value was used and meaningful. Really thanks Dimitre, the script do exactly what i want. thanks again for the explanation on how it works.
From: Atropo on 16 Jun 2010 12:33 On Jun 16, 8:52 am, Atropo <lxvasq...(a)gmail.com> wrote: > On Jun 16, 5:07 am, "Radoulov, Dimitre" <cichomit...(a)gmail.com> wrote: > > > > > On 15/06/2010 20.31, Atropo wrote: > > > > On Jun 15, 2:08 pm, Atropo<lxvasq...(a)gmail.com> wrote: > > >> On Jun 15, 11:03 am, "Radoulov, Dimitre"<cichomit...(a)gmail.com> > > >> wrote: > > > >>> On 15/06/2010 16.52, Atropo wrote: > > > >>>> On Jun 15, 10:27 am, "Radoulov, Dimitre"<cichomit...(a)gmail.com> > > >>>> wrote: > > >>>>> On 15/06/2010 15.52, Atropo wrote: > > > >>>>>> On Jun 14, 4:51 pm, "Radoulov, Dimitre"<cichomit...(a)gmail.com> wrote: > > >>>>>>> On 14/06/2010 22.47, Radoulov, Dimitre wrote: > > > >>>>>>>> On 14/06/2010 15.47, Atropo wrote: > > >>>>>>>>> Hi all, I'm on solaris 5.10 and trying to get several files from > > >>>>>>>>> windows server, but with the condition that the files do not have the > > >>>>>>>>> extension ".par" > > > >>>>>>> [...] > > > >>>>>>>> perl -MNet::FTP -e' > > >>>>>>>> ( $host, $user, $pass ) = @ARGV; > > >>>>>>>> $ftp = Net::FTP->new($host) or die "$@\n"; > > >>>>>>>> $ftp->login( $user, $pass ) or die $ftp->message; > > >>>>>>>> $ftp->binary; > > >>>>>>>> @files = grep !/\.par/, $ftp->ls; > > > >>> [...] > > > >>>>>> beside this i have a question. in ksh i can get rid off extension > > >>>>>> using ${file%.*}. how can i use this or something like in perl to > > >>>>>> avoid getting the files associates to '.par' files. > > > >>>>>> in this list i only want to get the last four files > > > >>>>>> LOC755225 > > >>>>>> LOC755225.par > > >>>>>> LOC705529 > > >>>>>> LOC705529.par > > >>>>>> LOC776480 > > >>>>>> LOC776480.par > > >>>>>> LOC786253 > > >>>>>> LOC786219 > > >>>>>> LOC786210 > > >>>>>> LOC786202 > > > >>>>> You could try something like this: > > > >>>>> perl -MNet::FTP -le' > > >>>>> ( $host, $user, $pass, $dir ) = @ARGV; > > >>>>> $ftp = Net::FTP->new($host) or die "$@\n"; > > >>>>> $ftp->login( $user, $pass ) or die $ftp->message; > > >>>>> $ftp->cwd($dir) or die $ftp->message; > > >>>>> $ftp->binary; > > >>>>> /(.*)\.par$/ and $files_ko{$1} = 1 > > >>>>> or push @files, $_ > > >>>>> for $ftp->ls; > > >>>>> $files_ko{$_} or $ftp->get($_) for @files; > > >>>>> $ftp->quit or die $ftp->message; > > >>>>> '<host> <user> <user> <dir> > > > >>> [...] > > > >>>> it runs but it brought > > >>>> everything. i run as it, 'coz i don't understand any after binary > > >>>> command > > > [...] > > > >> it works fine, was a typo of mine. but i still > > >> don't understand > > > >> /(.*)\.tag$/ and $files_ko{$1} = 1 > > >> or push @files, $_ > > >> for $ftp->ls; > > >> $files_ko{$_} or $ftp->get($_) for @files; > > > > if i want to delete the remote files i have transfer . could I use > > > @files or do all again like > > > > /(.*)\.tag$/ and $files_ko{$1} = 1 > > > or push @files, $_ > > > for $ftp->ls; > > > $files_ko{$_} or $ftp->delete($_) for @files;<= only changed > > > the "get" for "delete" > > > You could use something like this: > > > perl -MNet::FTP -le' > > ( $host, $user, $pass, $dir ) = @ARGV; > > $ftp = Net::FTP->new($host) or die "$@\n"; > > $ftp->login( $user, $pass ) or die $ftp->message; > > $ftp->cwd($dir) or die $ftp->message; > > $ftp->binary; > > /(.*)\.tag$/ and $files_ko{$1} = 1 > > or push @files, $_ > > for $ftp->ls; > > for (@files) { > > $ftp->get($_) and $ftp->delete($_) > > unless exists $files_ko{$_}; > > } > > $ftp->quit or die $ftp->message; > > ' <host> <user> <pass> <dir> > > > Here is the explanation: > > > /(.*)\.tag$/ and $files_ko{$1} = 1 # If a filename matches the > > # the pattern (.*)\.tag$, > > # store the string before .tag > > # in the hash table > > # (an associative array) > > # %files_ko as a key, the value > > # (1) in this case[1] > > # is irrelevant, > > # but in Perl it is mandatory (it > > # could be even undefined, > > # but it should be explicitly > > # mentioned (unlike awk). > > or push @files, $_ # Otherwise, store the filename > > # in the array @files > > for $ftp->ls; # The ls method returns the list > > # with the filenames. > > > for (@files) { > > $ftp->get($_) and $ftp->delete($_) # Get and delete the file, > > unless exists $files_ko{$_}; # unless such a key > > # exists in the hash > > # %files_ko. > > > HTH > > > Dimitre > > > [1] In my previous code both key and value was used and meaningful. > > Really thanks Dimitre, the script do exactly what i want. thanks again > for the explanation on how it works. One very last thing. how can i create a log file with the names of the files i had fetched. and append to this file everytime this script runs.
From: Radoulov, Dimitre on 17 Jun 2010 02:40 On 16/06/2010 18.33, Atropo wrote: > On Jun 16, 8:52 am, Atropo<lxvasq...(a)gmail.com> wrote: >> On Jun 16, 5:07 am, "Radoulov, Dimitre"<cichomit...(a)gmail.com> wrote: >> >> >> >>> On 15/06/2010 20.31, Atropo wrote: >> >>>> On Jun 15, 2:08 pm, Atropo<lxvasq...(a)gmail.com> wrote: >>>>> On Jun 15, 11:03 am, "Radoulov, Dimitre"<cichomit...(a)gmail.com> >>>>> wrote: >> >>>>>> On 15/06/2010 16.52, Atropo wrote: >> >>>>>>> On Jun 15, 10:27 am, "Radoulov, Dimitre"<cichomit...(a)gmail.com> >>>>>>> wrote: >>>>>>>> On 15/06/2010 15.52, Atropo wrote: >> >>>>>>>>> On Jun 14, 4:51 pm, "Radoulov, Dimitre"<cichomit...(a)gmail.com> wrote: >>>>>>>>>> On 14/06/2010 22.47, Radoulov, Dimitre wrote: >> >>>>>>>>>>> On 14/06/2010 15.47, Atropo wrote: >>>>>>>>>>>> Hi all, I'm on solaris 5.10 and trying to get several files from >>>>>>>>>>>> windows server, but with the condition that the files do not have the >>>>>>>>>>>> extension ".par" [...] > One very last thing. how can i create a log file with the names of the > files i had fetched. and append to this file everytime this script > runs. perl >> ftp.log -MNet::FTP -le' ( $host, $user, $pass, $dir ) = @ARGV; $ftp = Net::FTP->new($host) or die "$@\n"; $ftp->login( $user, $pass ) or die $ftp->message; $ftp->cwd($dir) or die $ftp->message; $ftp->binary; /(.*)\.tag$/ and $files_ko{$1} = 1 or push @files, $_ for $ftp->ls; for (@files) { $ftp->get($_) and $ftp->delete($_) and print unless exists $files_ko{$_}; } $ftp->quit or die $ftp->message; ' <host> <user> <pass> <dir> Regards Dimitre
From: Atropo on 17 Jun 2010 11:46 On Jun 17, 2:40 am, "Radoulov, Dimitre" <cichomit...(a)gmail.com> wrote: > On 16/06/2010 18.33, Atropo wrote: > > > > > On Jun 16, 8:52 am, Atropo<lxvasq...(a)gmail.com> wrote: > >> On Jun 16, 5:07 am, "Radoulov, Dimitre"<cichomit...(a)gmail.com> wrote: > > >>> On 15/06/2010 20.31, Atropo wrote: > > >>>> On Jun 15, 2:08 pm, Atropo<lxvasq...(a)gmail.com> wrote: > >>>>> On Jun 15, 11:03 am, "Radoulov, Dimitre"<cichomit...(a)gmail.com> > >>>>> wrote: > > >>>>>> On 15/06/2010 16.52, Atropo wrote: > > >>>>>>> On Jun 15, 10:27 am, "Radoulov, Dimitre"<cichomit...(a)gmail.com> > >>>>>>> wrote: > >>>>>>>> On 15/06/2010 15.52, Atropo wrote: > > >>>>>>>>> On Jun 14, 4:51 pm, "Radoulov, Dimitre"<cichomit...(a)gmail.com> wrote: > >>>>>>>>>> On 14/06/2010 22.47, Radoulov, Dimitre wrote: > > >>>>>>>>>>> On 14/06/2010 15.47, Atropo wrote: > >>>>>>>>>>>> Hi all, I'm on solaris 5.10 and trying to get several files from > >>>>>>>>>>>> windows server, but with the condition that the files do not have the > >>>>>>>>>>>> extension ".par" > > [...] > > > One very last thing. how can i create a log file with the names of the > > files i had fetched. and append to this file everytime this script > > runs. > > perl >> ftp.log -MNet::FTP -le' > ( $host, $user, $pass, $dir ) = @ARGV; > $ftp = Net::FTP->new($host) or die "$@\n"; > $ftp->login( $user, $pass ) or die $ftp->message; > $ftp->cwd($dir) or die $ftp->message; > $ftp->binary; > /(.*)\.tag$/ and $files_ko{$1} = 1 > or push @files, $_ > for $ftp->ls; > for (@files) { > $ftp->get($_) and $ftp->delete($_) and > print unless exists $files_ko{$_}; > } > $ftp->quit or die $ftp->message; > ' <host> <user> <pass> <dir> > > Regards > Dimitre before asking you i was trying this, according to tutorials. why it did not work? perl -MNet::FTP -le' ( $host, $user, $pass, $dir ) = @ARGV; $my_file = "recibidos.txt"; OPEN(PLOT,">>$my_file") or die("The file cannot be opened!"); $ftp = Net::FTP->new($host) or die "$@\n"; $ftp->login( $user, $pass ) or die $ftp->message; $ftp->cwd($dir) or die $ftp->message; $ftp->binary; /(.*)\.tag$/ and $files_ko{$1} = 1 or push @files, $_ for $ftp->ls; for (@files) { $ftp->get($_) and $ftp->delete($_) unless exists $files_ko{$_}; print PLOT "$_\n"; } $ftp->quit or die $ftp->message; CLOSE(PLOT) ' <host> <user> <pass> <dir>
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: Launch and exit the browser Next: Huge mailbox split? |