|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
Hi
the script below generates this error Cannot open T:\OUT\VERIFS No such file or directory Code:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
use strict;
use warnings;
use DBI;
my $MyFolder = 'T:\OUT\VERIFS';
opendir(DIR, $MyFolder) or die ("Cannot open $MyFolder $!\n");
my @VerFiles = grep /\.ver/, (readdir DIR);
chomp @VerFiles;
foreach my $item (@VerFiles){
if (substr ($item, 0, 3) eq '716'){
my $MyTarget = "${MyFolder}\\$item";
&insertRec($MyTarget);
}
}
sub insertRec{
my $filename = shift;
my $zone = substr($filename, 19, 3);
my $network = substr($filename, 17, 2);
my $DSN = 'driver={SQL Server};Server=SERVER1;database=VerifDB;uid=sa;pwd=password';
my $dbh = DBI->connect("dbi:ODBC:$DSN",'sa','password') or die "$DBI::errstr\n";
open(FILE, $filename) or die ("Cannot open the file because: $!");
while(<FILE>){
my ($LOI,$DateAired,$ScheduledTime,$blah1,$blah2,$blah3,$blah4,$blah5,$ActualAirTime,$ActualAirLength,$ ActualAirPos,$SpotID,$Status) = split (' ', $_);
if($LOI eq 'LOI'){
my $sql = "INSERT INTO VerificationFiles VALUES ($zone,$network,'$DateAired','$ScheduledTime','$ActualAirTime','$ActualAirLength','$ActualAirPos' ,'$SpotID','$Status')";
my $sth = $dbh->prepare($sql);
$sth->execute();
$sth->finish;
}
}
close(FILE);
$dbh->disconnect;
}
closedir DIR;
print "<html><body>";
print "<h3> New records have been created!</h3>";
print "</body></html>";
i had a problem with reaching the T:\OUT\Verifs folder. However, I have full access to open, read any files in that folder. the files i am trying to read resides on server2, the perl script will be posted on server1. when someone runs the scipt from user1 machine, it will open up those files on server2, read thru, extract some fields and then insert into a DB on server1. i think i have a similar problem with the following script. Code:
use strict; use warnings; open (FH, "T:/OUT/61012049.ver") or die $!; print while (<FH>); when i save this on server1 and try to run it from there, it gives Permission denied at D:\Montana\Fails\test.pl by the way, d: is server1 and t: is server2. t: is mapped on server1. i would rather use the full UNC path. something like "//novardb1/tnb1/out/verifs" for the server2. Last edited by edwinbrains : July 31st, 2004 at 04:19 AM. |
|
#2
|
|||
|
|||
|
Your script looks like Unix related and T: ??? Unix does not have T: style of pointing to folders. It should be instead, /usr/local/....
|
|
#3
|
|||
|
|||
|
Quote:
this is actually a windows 2000 server. i tried almost everything, with full unc paths without them and still couldn't get it to work.. |
|
#4
|
|||
|
|||
|
Did you try running the script locally? I don't think perl compiler on box a will be able to open file on box b and vice versa.
|
|
#5
|
|||
|
|||
|
Quote:
everything works just fine on my machine. it opens up those files on the server2, reads them, inserts them into the DB. but the problem starts when i move the script on the server1 and try to run it from there. i will award you if you help me solve this problem... thanks |
|
#6
|
|||
|
|||
|
Does Server 1 have permissions to access files on Server 2? Also, when you copy the file on Server1 from your local - are you ftp'ing? Or just copy paste, sometimes if you copy Perl scripts in binary mode then they start acting up. It is really hard for me to help since I cannot see your environment - I don't think there is anything wrong with your script, it seems like some networking, file permissions issue.
|
|
#7
|
|||
|
|||
|
Quote:
i aggree. i save the script on server1. and server1 has permissions to access files on server2. my files are saved under \\server1\montana\fails and from there i try to reach \\server2\tnb1\out. will that be the problem? |
|
#8
|
|||
|
|||
|
The path you mentioned here is different then the one in the script! Are they pointing to the right place? Does the file already exist on the Server? If not then try creating one and then running the script. Other then that I really can't think of anything else...
|
![]() |
| Viewing: Dev Shed Forums > Other > Hire A Programmer > NEED Pro Help! Will Pay |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|