On Wednesday 11 May 2005 23.32, Markus Natter wrote:
On 5/11/05, Rikard Johnels
wrote: Hello all! I have a script that has started to die on me since installing 9.3
i get rikjoh@sparhawk:~> perl bin/transfer_cam.pl No such file or directory
The code is a s follows:
#!/usr/bin/perl use strict; use warnings;
my $dst_dir = "/mnt/network/linux/hdc/Pictures";
my $src_dir; for(1..10){ { open my $in,"/proc/mounts" or die "$!\n"; $/=undef; ($src_dir) = <$in>=~/ (\S*usb-\S*)/; close $in; } last if defined $src_dir; sleep 2; }
die "Could not calculate \$src_dir" unless defined $src_dir; my @time = localtime(time);
my( $year ) = $time[5]=~/(\d\d)$/; my $month = $time[4]+1; $month="0$month" if $month<10; my $day = $time[3]; $day="0$day" if $day<10;
$dst_dir.="/$year/$month/$year$month$day";
my $xx="01"; while( -d "$dst_dir.$xx" ){ $xx++; } $dst_dir.=".$xx";
mkdir $dst_dir or die "$!\n"; `cp -r $src_dir/dcim/100pentx/* $dst_dir/`;
Can anyone help me? Where and why is it barfing? --
/Rikard
" Sharing knowledge is the most fundamental act of friendship. Because it is a way you can give something without loosing something." -R. Stallman
--------------------------------------------------------------- Rikard Johnels email : rikjoh@norweb.se Mob : +46 763 19 76 25 PGP : 0x461CEE56 ---------------------------------------------------------------
-- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
Hi,
it looks like, as it appears to me in a very short test, that you are trying to create a directory containing the current date as a subfolder structure..
i mean this line where you append the date to $dst_dir:
$dst_dir.="/$year/$month/$year$month$day";
and a counting number.. ( on a new day it will be allways "01" because the "-d" returns false.. )
$dst_dir.=".$xx";
and this line where you try to create it:
mkdir $dst_dir or die "$!\n";
Given this, the whole substructure is build up dynamicly, in other words it changes every day at least 2 subfolders ( $day and $xx ). You're trying to create it recursively which should not work with the perl mkdir command..
And it fails on my 9.2 box at home as i expected. If i did understand you right you'd wanted to create the whole path ( until $xx ) at once if does not exist. You could give mkpath from the file::Path module a try..
Markus
How do i invole that command? /me is just not a programer... :( -- /Rikard " Sharing knowledge is the most fundamental act of friendship. Because it is a way you can give something without loosing something." -R. Stallman --------------------------------------------------------------- Rikard Johnels email : rikjoh@norweb.se Mob : +46 763 19 76 25 PGP : 0x461CEE56 ---------------------------------------------------------------