CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Accessing Solaris Directory

 



abhisri
Novice

Jul 17, 2006, 10:06 AM

Post #1 of 4 (962 views)
Accessing Solaris Directory Can't Post

Hello

I have a perl script which scans and moves the files to another directory. The script is working fine on NT environment. I changed the script so that the destination directory would be in solaris environment and the script says "destination directory does not exists" did I give the correct path in script...if not how can I give the path...I have my user profile set up in solaris box...

$base_dir="/home/abhisri/testdir";
$source_dir="E:/Scripts/Perl/";
$destination_dir="$base_di";
$file_name = "F*.pos";

scanDir($source_dir);

scanDir ($base_dir);

sub scanDir
{
$src_dir = $_[0];
opendir(DIR, $src_dir) || die "Error: Could not Open Input Directory $src_dir";
opendir(DIR,$src_dir);
$name = "(?i)". $file_name;
print "\n $name \n";
my @files = grep (/$file_name/, readdir(DIR));
closedir(DIR);

foreach (@files)
{
$file = $_;
print $file
}

}

sub moveFile()
{
$src_dir = $_[0];
$move_dir = $_[1];
$ret = system ("mv $src_dir $move_dir");
if ($ret == 0){

print "\n File Moved Successfully \n";

}

print "\nMoved File to Destination Folder Result --> $ret \n";
}

}


KevinR
Veteran


Jul 17, 2006, 11:07 AM

Post #2 of 4 (960 views)
Re: [abhisri] Accessing Solaris Directory [In reply to] Can't Post

an example of why you should be using "stict":

$base_dir="/home/abhisri/testdir";
$source_dir="E:/Scripts/Perl/";
$destination_dir="$base_di";
-------------------------------------------------


abhisri
Novice

Jul 17, 2006, 11:46 AM

Post #3 of 4 (957 views)
Re: [KevinR] Accessing Solaris Directory [In reply to] Can't Post

thanks for finding the mistake. But I am not using $destination for opening directory..I am using sub module scan directory to scan directory and list files...when open(DIR, $src_dir) is executed it says unable to find directory.


KevinR
Veteran


Jul 18, 2006, 9:43 AM

Post #4 of 4 (954 views)
Re: [abhisri] Accessing Solaris Directory [In reply to] Can't Post

why do you have it twice?


Code
opendir(DIR, $src_dir) || die "Error: Could not Open Input Directory $src_dir"; 
opendir(DIR,$src_dir);


do this and see if it helps track down the problem:


Code
opendir(DIR, $src_dir) or die "Error: Could not Open Input Directory $src_dir, the reason is: $!";


$! should have a more detailed error message. It might or might not help figure out the reason why the folder can't be opened.

I don't know anything about Solaris so I don't know why it doesn't like your code.
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives