[wplug] perl / cron problem
Jonathan Billings
billings at negate.org
Fri Oct 21 16:36:37 EDT 2005
Mike S wrote:
>> This seems like a rather pointless function. Why don't you replace any
>> run(...) functions with "system(...) == 0 or die ...". Also, "my @args
>> = shift" only puts the first argument in @args, so you're only running
>> system with the first parameter passed to run(). You're probably
>> running the run(...) function with only one parameter, so you haven't
>> encountered any problems yet.
>
> That is the case, and I really like my code better with:
> run('tar czvf xyz abc');
> rather than
> system('tar czvf xyz abc') == 0 or die ('error: What do you know...');
> because its a lot easier to type.
You'll still probably want to fix the bug in your code. You should say
"my @args = @_" instead of "my @args = shift" which has an implicit
'shift @_'.
I understand the need to have readable code. :)
>> You could have it store and print the exit status of the system()
>> command, to see what the return value of it was.
>
> I am going to give that a whirl. Does system return an integer?
It returns an integer masked by the return code of the shell that
executed the command, because you're passing a string containing a
command with arguments. If you read the perldoc page for 'system' by
running "perldoc -f system" you'll see more about it.
--
Jonathan S. Billings <billings at negate.org>
More information about the wplug
mailing list