E
erik
I am using expect to get firewall configs and then write them to a FH.
My issue is the I cannot get the $date to work within the FH, therefore
it does not write the file.
Here is my subfunction:
#############################################################
sub write_config{
$date = qx(date +%x);
$date =~ s/\//-/g;
print " THE DATE IS: $date";
#qx(touch /vault/var/ns-config/ns-$date/$device-$date);
qx(mkdir /vault/var/ns-config/$date/);
$filename = "/vault/var/ns-config/$date/$device";
open(IN, ">$filename") || die ("Open Failed: $!\n");
print IN "$config_capture\n";
sleep 3;
#qx(/bin/gzip /vault/var/ns-config/$date/$device-$date);
};#end sub
############################################################
At run time, I get this...
THE DATE IS: 11-13-2005
mkdir: cannot create directory `/vault/var/ns-config/11-13-2005': File
exists
sh: line 1: /: is a directory
Open Failed: No such file or directory
The mkdir error is expected because I have run this many times. You can
disregard that. But the issue appears to be an issue with $date in the
$filename variable.
If I change $filename from the original $filename =
"/vault/var/ns-config/$date/$device";
to
$filename = "/vault/var/ns-config/11-13-2005/$device";
It works fine. What is wrong with $date in this context?
My issue is the I cannot get the $date to work within the FH, therefore
it does not write the file.
Here is my subfunction:
#############################################################
sub write_config{
$date = qx(date +%x);
$date =~ s/\//-/g;
print " THE DATE IS: $date";
#qx(touch /vault/var/ns-config/ns-$date/$device-$date);
qx(mkdir /vault/var/ns-config/$date/);
$filename = "/vault/var/ns-config/$date/$device";
open(IN, ">$filename") || die ("Open Failed: $!\n");
print IN "$config_capture\n";
sleep 3;
#qx(/bin/gzip /vault/var/ns-config/$date/$device-$date);
};#end sub
############################################################
At run time, I get this...
THE DATE IS: 11-13-2005
mkdir: cannot create directory `/vault/var/ns-config/11-13-2005': File
exists
sh: line 1: /: is a directory
Open Failed: No such file or directory
The mkdir error is expected because I have run this many times. You can
disregard that. But the issue appears to be an issue with $date in the
$filename variable.
If I change $filename from the original $filename =
"/vault/var/ns-config/$date/$device";
to
$filename = "/vault/var/ns-config/11-13-2005/$device";
It works fine. What is wrong with $date in this context?