Hi there. I've wrestled with this for days now, and haven't gotten anywhere. I'm using Perl to make web-based glue-code for an import (of log files) script. Summary of the problem is: "after a long running process system("import $file"), my system("mv $file /tmp/trash") isn't working" Here are more details...

Scenario is:

/var/log/newlogs/One_Log_Dir/log.txt, screenshots.jpg, etc.

So... put up a web-page with checkboxes and the output of:

@files = `find /var/log/newlogs -name log.txt -maxdepth 2`
(remember, this is glue-code, so I'm not using / learning readdir / opendir, etc yet).

...and after a submission (where $cgi->param('logs') is filled with checkboxed selected items...)

for my $log ( @logs ) { add_and_trash( $log ) }

Where add_and_trash() is something like:

sub add_and_trash { my ($name) = @_; my $newname = `convert $name`; print "<hr>\n"; my $cmd1 = "/tools/addbundle.pl $newname"; print $cmd1. "<hr>\n"; system( $cmd1 ); # can take ~2-3 minutes my $cmd2 = "mv $newname /tmp/trashed"; print $cmd2. "<hr>\n"; system( $cmd2 ); }

Can anyone see any problems? Every single function call is being called correctly. If I take the copy/paste of the print $cmd's and paste them manually into a bash session, everything works, it's only when run from the perl front-end that it bombs.

`whoami` reports back 'rames', not 'nobody'. Any ideas / assistance would be welcome. Sorry for chopping apart the script (it's long and boring, otherwise), hopefully my perl-fu is strong enough that I didn't make any syntax errors while paring it down.

I've done reading with perldoc perlops (for ``), and perldoc -f system, but just can't figure out why when *I* copy and paste the commands by hand it works, but perl (perl/cgi running through apache) can't get it working.

Assistance is appreciated, I'll respond with more details if there are parts that I'm missing.

--Robert


In reply to system( 'mv ...' ) not working? by ramses0

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.