Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Further to this thread, in which I try to write a utility script to make my newly uploaded files executable, I've now got my ISP to let me run scripts suEXEC. And, bearing in mind the helpful comments on my recently posted other code I have pared my script down to the script you see at the end of this node.(if sibling pixel should read this - note that I have taken to heart your advice about how to use, for which again thanks).

So that's fine. It works. It toggles the file permissions of files in a given directory. BUT... does it toggle them from 644 to 755? It does not! It toggles them from 204 to 363. It consistently chmods files to 204 when I want 644 and 363 when I want 755. And it does the same thing if I try 0755 and 0644. I'm puzzled.

Is this something wrong with my script? If so, I'd be very grateful to know what. Or is it some obvious thing outside the script I should check - again, any advice gratefully received.

Here's the code:
#!/usr/bin/perl -w use strict; use CGI qw(:standard); print header, start_html( -title=>'CHMOD UTILITY' ); &do_chmod if param; &send_form; sub do_chmod { for (param('Dirs')) { my @files; push @files, $_ while <$_*.p*>; if (chmod param('Action'), @files) { print "Changed permissions on " . join(" ; ",@files) . " t +o " . param('Action') . "<BR>"; } else { print "Could not change permissions on " . join(" ; ",@fil +es) . " to " . param('Action') . "<BR>"; } } print "DONE"; } sub send_form { my @dirs; push @dirs, $_ while <../*/>; print startform( -name=>'mainform', -method=>'POST', -action=>'', ), checkbox_group( 'Dirs', [@dirs], [], 1, ), submit( -name=>'Action', -value=>'0755', ), submit( -name=>'Action', -value=>'0644', ), endform, end_html; }
Thanks to all,

George Sherston

In reply to Ongoing chmod lack of success by George_Sherston

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2021-11-27 09:41 GMT
Find Nodes?
    Voting Booth?

    No recent polls found