I wanted to create a perl script to check if a directory exists, and if it doesnt i want to crate one.It doesnt work in /etc,whereas the same code runs in other directories.any help would be appreciated.
my $username = getpwuid( $< ); print "$username\n"; if($username ne "root"){ print "please run this script as root.\nsudo perl automation.pl\n +"; exit; }else{ opendir(ETC,"/etc"); unless(-d "Automation"){ mkdir("Automation"); opendir(AUTOMATION,"Automation"); + open(CRONTABFILE,">crontab"); flock(CRONTABFILE +,2); $cronjob = "0 12 * * * /usr/bin/perl /etc/Automation/aptscript.pl"; + print CRONTABFILE "$cronjob"; close(CRONTABFILE); + open(APTSCRIPT,">aptscript.pl"); flock(APTSC +RIPT,2); print APTSCRIPT <<'EOF'; #!/usr/bin/perl + print "replace this script with the logic of the download of the deb f +ile"; EOF close(APTSCRIPT); closedir(AUTOMATION); closedir(ETC); } }
In reply to detecting directory in perl by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |