Hi,
I’m trying to get information from the SQL server and with this information I like to create directories on a Windows Server share.
The following script works fine except the creation of the directories on the Windows Server share is not working?
--------------------------------------------------------
#!/usr/local/bin/perl -w
use strict;
use Errno;
use Getopt::Std;
use Win32::ODBC;
use Time::Local;
my $SHARE = "\\\\Server1\\Test";
my $db="";
$db = new Win32::ODBC("infoDB");
if ($db)
{
writeLogFile($out, "$dsn allocated\n") if ($out);
}
if ( !$db->Sql("SELECT * FROM repsrv WHERE (targetSrv = 'Server1')"))
{
while ($db->FetchRow())
{
($id, $localSrv, $sourceDir, $targetDir) = $db->Data("NO", "localSrv", "sourceDir", "targetDir");
#print "$id, localSrv='$localSrv', sourceDir='$sourceDir', targetDir='$targetDir'\n";
print "$SHARE\\$localSrv\\$sourceDir\n";
system("mkdir $SHARE\\$localSrv\\$sourceDir ");
}
}
$db->Close();
-------------------------------------------------------
The output from print is:
\\Server1\Test\DellSrv1\F:\TimeTest
\\Server1\Test\HPSrv1\D:\Data\Groups
\\Server1\Test\IBMSrv1\E:\Home\Users
The error is “The specified path is invalid.”
I’m using the system("mkdir $SHARE\\$localSrv\\$sourceDir "); to create the directory. And output of $sourceDir= D:\Data\Groups
My feeling is that the : and the single \ is generating my problem, if yes how can I remove the : and create a double \\ in $sourceDir string.
I don’t now how to do this
Thanks,
Navmen
I’m trying to get information from the SQL server and with this information I like to create directories on a Windows Server share.
The following script works fine except the creation of the directories on the Windows Server share is not working?
--------------------------------------------------------
#!/usr/local/bin/perl -w
use strict;
use Errno;
use Getopt::Std;
use Win32::ODBC;
use Time::Local;
my $SHARE = "\\\\Server1\\Test";
my $db="";
$db = new Win32::ODBC("infoDB");
if ($db)
{
writeLogFile($out, "$dsn allocated\n") if ($out);
}
if ( !$db->Sql("SELECT * FROM repsrv WHERE (targetSrv = 'Server1')"))
{
while ($db->FetchRow())
{
($id, $localSrv, $sourceDir, $targetDir) = $db->Data("NO", "localSrv", "sourceDir", "targetDir");
#print "$id, localSrv='$localSrv', sourceDir='$sourceDir', targetDir='$targetDir'\n";
print "$SHARE\\$localSrv\\$sourceDir\n";
system("mkdir $SHARE\\$localSrv\\$sourceDir ");
}
}
$db->Close();
-------------------------------------------------------
The output from print is:
\\Server1\Test\DellSrv1\F:\TimeTest
\\Server1\Test\HPSrv1\D:\Data\Groups
\\Server1\Test\IBMSrv1\E:\Home\Users
The error is “The specified path is invalid.”
I’m using the system("mkdir $SHARE\\$localSrv\\$sourceDir "); to create the directory. And output of $sourceDir= D:\Data\Groups
My feeling is that the : and the single \ is generating my problem, if yes how can I remove the : and create a double \\ in $sourceDir string.
I don’t now how to do this
Thanks,
Navmen