Illegal seek

E

Eric

Hello,

Sometimes I get the error message: "Illegal seek". An example of this
is when I have the following in a Perl script:

my $run = "touch abc";
`$run` || print STDERR "Command '$run' failed: $! \n";

The error message I get is:

Command 'touch abc' failed: Illegal seek

Yet, the file 'abc' is created/updated.

But when $run = "ls -las", I don't get this error message.

Does anyone know why I am getting this error? Is there a better way to
accomplish the same thing?

Eric
 
U

Uri Guttman

E> my $run = "touch abc";
E> `$run` || print STDERR "Command '$run' failed: $! \n";

why are you using backticks when you don't want the output? the return
value of `` IS NOT an error message.

E> The error message I get is:

E> Command 'touch abc' failed: Illegal seek

you are likely getting some other error message left in $! as the
backticks always worked. any error touch makes would not be return in
the backticks but in $@.

E> Does anyone know why I am getting this error? Is there a better way to
E> accomplish the same thing?

perldoc -f utime

no reason to fork out as perl has it builtin.

uri
 
E

Eric

E> my $run = "touch abc";
E> `$run` || print STDERR "Command '$run' failed: $! \n";

why are you using backticks when you don't want the output? the return
value of `` IS NOT an error message.

E> The error message I get is:

E> Command 'touch abc' failed: Illegal seek

you are likely getting some other error message left in $! as the
backticks always worked. any error touch makes would not be return in
the backticks but in $@.

E> Does anyone know why I am getting this error? Is there a better way to
E> accomplish the same thing?

perldoc -f utime

no reason to fork out as perl has it builtin.

uri

Thanks for your response.

We do in fact want the response, at least when in verbose mode. For
clarity reasons, I didn't include all of the code.

As far as the 'touch' command goes, this is not the actual command we
are running. I changed it to this for simplicity reasons.

Having said this, I still am not clear on why I am getting the error
message with some commands but not others.

Eric
 
J

John W. Krahn

Eric said:
Sometimes I get the error message: "Illegal seek". An example of this
is when I have the following in a Perl script:

my $run = "touch abc";
`$run` || print STDERR "Command '$run' failed: $! \n";

The error message I get is:

Command 'touch abc' failed: Illegal seek

Yet, the file 'abc' is created/updated.

But when $run = "ls -las", I don't get this error message.

Does anyone know why I am getting this error? Is there a better way to
accomplish the same thing?

Yes, you want to do this instead:

my @args = ( 'touch', 'abc' );
system( @run ) == 0 or print STDERR "Command '@run' failed: $? \n";



John
 
J

John W. Krahn

Uri said:
E> my $run = "touch abc";
E> `$run` || print STDERR "Command '$run' failed: $! \n";

why are you using backticks when you don't want the output? the return
value of `` IS NOT an error message.

E> The error message I get is:

E> Command 'touch abc' failed: Illegal seek

you are likely getting some other error message left in $! as the
backticks always worked. any error touch makes would not be return in
the backticks but in $@.

I think you mean $? instead of $@.


John
 
U

Uri Guttman

E> my $run = "touch abc";
E> `$run` || print STDERR "Command '$run' failed: $! \n";
JWK> I think you mean $? instead of $@.

probably. i always confuse those and either rtfm or find other code
where i used the right one. :) in general i don't use backticks too
often anyway. i know what perl has builtin and i use backticks for
their output, not success/failure results.

uri
 
E

Eric

Eric schreef:


:(

Sorry for not following the group protocal. Here is the code. The
launch.pl file runs the mountDefaultBuild.pl script.

===========================================

File: launch.pl:
----------------

#! /usr/bin/perl -w

use strict;

my $script = "/usr/local/mountDefaultBuild.pl";

`$script` || print STDERR "Command '$script' failed: $?";


File: mountDefaultBuild.pl
--------------------------

#! /usr/bin/perl -w

use strict;
use Fcntl qw:)DEFAULT :flock);

my $execute = "/usr/sbin/exportfs -r";
my $umount = "umount /networkinstall/default";
my $mount = "mount -o loop /networkinstall/tmp/build.iso /
networkinstall/default";

unless (open SEMAPHORE, "> /tmp/mounts.lock") {
print STDOUT "unexpected problem opening /tmp/mounts.lock\n";
}
flock SEMAPHORE, Fcntl::LOCK_EX;

`$execute` || print STDERR "Command '$execute' failed: $?\n";
`$umount` || print STDERR "Command '$umount' failed: $?\n";
`$mount` || print STDERR "Command '$mount' failed: $?\n";
`$execute` || print STDERR "Command '$execute' failed: $?\n";

close SEMAPHORE;

===========================================

Thanks.

Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top