Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Illegal Seek from system() with no output from $?

by c (Hermit)
on Mar 27, 2002 at 02:37 UTC ( #154567=perlquestion: print w/replies, xml ) Need Help??

c has asked for the wisdom of the Perl Monks concerning the following question:

The title pretty much describes what I am seeing. Actually, the return from $? is 0. I read over this which had made me think that $? would hold more info than the $! that I had been using, but to no avail.

I'm doing a pretty simple rcs checkout, move a file over another and then checking back in:

my $checkout = "co -q -l"; my $checkin = "ci -u -q -m\"Modification of $domain\""; ## check out file from rcs system("$checkout $revdns") or warn "Problems with checking out $revdns : $!\n"; ## move the tmp file into its place move("$tmp_revdns","$revdns") or warn "Problems moving $tmp_revdns to $revdns : $!\n"; ## check the new file into rcs system("$checkin $revdns") or warn "Problems with checking in $revdns : $?\n"; print "inverse dns records created!\n";

I get the warn statement with the first system call. Any ideas on why I would receive this?

humbly -c

Replies are listed 'Best First'.
•Re: Illegal Seek from system() with no output from $?
by merlyn (Sage) on Mar 27, 2002 at 05:12 UTC
    The value of $! is not useful or defined when it's not checked immediately after a failed system call (which doesn't include system, which is really a macro for a combination of fork/exec/wait steps). So, you're getting bogus results from a bogus operation -- not surprising. {grin}

    -- Randal L. Schwartz, Perl hacker

Re: Illegal Seek from system() with no output from $?
by vek (Prior) on Mar 27, 2002 at 07:34 UTC
    system returns 0 on success and 1 on failure. Whenever you use system you should be using and to check for failure instead of or:
    system("$checkout $revdns") and warn "Problems with checking out $revdns : $!\n";
Re: Illegal Seek from system() with no output from $?
by lestrrat (Deacon) on Mar 27, 2002 at 02:56 UTC

    I think system() returns the exit status of the command ( i.e. $? ) -- so if your command executed properly, then it would most likely return a 0, which is a logical "false" for perl. So you need to warn when:

    system( "$your_command" ); if( $? != 0 ) { warn "something's wrong"; } ## or ## ( system( "$cmd" ) == 0 ) or warn "the sky is falling!"; ##

    I don't know about the illegal seek stuff, but I used to get a lot of that when I would have bogus errors ( i.e. my bug ) in the code. It's probably just that $! was never meant to be set when you checked for it ( however, I'm no expert on this subject, so please take that statement with a grain of salt )

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://154567]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2023-06-01 14:43 GMT
Find Nodes?
    Voting Booth?

    No recent polls found