Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Sorry to trouble you with what may be a trivial prob, but I'd be grateful if any monk wd cast a critical eye over the following.

It's a little utility for when I upload my scripts from my win98 machine to my Linux web space. Whilst I'd value comments on the structure of the script (and am even prepared to be told there's already a module to do this), what I'm stumped on is how to get chmod to work.

The simple statement of the problem is, it doesn't work. The file permissions stay the same. And even when I replace $_ with the name of a file in the dir it doesn't work. I know next to nothing about system administration, and it may well be some webspace / OS specific problem - I'd be grateful for any thoughts on that. But if it's in the code, please hit me with a haddock.

Yer tiz:
print $q->header; print $q->start_html; while (<*.pl>) { next if $_ eq 'replace.pl'; print "<B>$_</B><BR>"; $old = $_; open GET, $old; print "opening $old<BR>"; $new = substr($old,0,(length $old) -2) . 'bak'; open PUT, ">$new"; print "opening $new<BR>"; print PUT $_ while <GET>; print "writing $old into $new<BR>"; close GET; close PUT; print "closing $old and $new<BR>"; open GET, "$new"; open PUT, ">$old"; print "reopening $old and $new<BR>"; while (<GET>) { $_ =~ s/c:\\perl\\bin\\perl/\/usr\/bin\/perl/; $_ =~ s/\("DBI:mysql:database=foo"\)/("DBI:mysql:database=foo" +,"bar","baz")/; print PUT $_; } print "altering lines in $new and writing to $old<BR>"; close GET; close PUT; print "closing $old and $new<BR>"; $cnt = chmod 0755, $old; if ($cnt) { print "changing file permissions for $old<BR>"; } else { print "cannot change file perms for $old<BR>"; } print "<BR>"; } print "DONE"; print $q->end_html;


§ George Sherston

In reply to can't get chmod to work by George_Sherston

Title:
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 How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-23 11:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found