Total Pageviews

Friday, April 13, 2012

Use chmod in Perl

chmod(0777, "hohofiles") || print $!;
This will change the permissions of our directory hohofiles to 777.
-We called Perl's built-in chmod function.
-We set permissions to 777.
-We enclosed the name of the thing to be chmoded in quotation marks. This could have also included the path to hohofiles if it was in a different directory than our script.
-We included two vertical bars or pipes, which mean "or".
-We said to print any error we might receive. The errors are contained in the built-in variable $!
-Summary: chmod our directory or print errors.
Copy and Paste Perl Code:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
chmod(0777, "hohofiles") || print $!;
print " -Done";
exit;

No comments:

Post a Comment