Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Illegal seek

Reply
Thread Tools

Illegal seek

 
 
Eric
Guest
Posts: n/a
 
      04-13-2007
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

 
Reply With Quote
 
 
 
 
Uri Guttman
Guest
Posts: n/a
 
      04-13-2007
>>>>> "E" == Eric <(E-Mail Removed)> writes:

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

--
Uri Guttman ------ http://www.velocityreviews.com/forums/(E-Mail Removed) -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
 
Reply With Quote
 
 
 
 
Eric
Guest
Posts: n/a
 
      04-13-2007
On Apr 13, 2:24 pm, Uri Guttman <(E-Mail Removed)> wrote:
> >>>>> "E" == Eric <(E-Mail Removed)> writes:

>
> 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
>
> --
> Uri Guttman ------ (E-Mail Removed) --------http://www.stemsystems.com
> --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
> Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org


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

 
Reply With Quote
 
John W. Krahn
Guest
Posts: n/a
 
      04-14-2007
Eric wrote:
>
> 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
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
 
Reply With Quote
 
John W. Krahn
Guest
Posts: n/a
 
      04-14-2007
Uri Guttman wrote:
>>>>>>"E" == Eric <(E-Mail Removed)> writes:

>
> 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
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
 
Reply With Quote
 
Uri Guttman
Guest
Posts: n/a
 
      04-14-2007
>>>>> "JWK" == John W Krahn <(E-Mail Removed)> writes:

JWK> Uri Guttman wrote:
>>>>>>> "E" == Eric <(E-Mail Removed)> writes:

>>

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 $@.


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

--
Uri Guttman ------ (E-Mail Removed) -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
 
Reply With Quote
 
Dr.Ruud
Guest
Posts: n/a
 
      04-14-2007
Eric schreef:

> For
> clarity reasons, I didn't include all of the code.




--
Affijn, Ruud

"Gewoon is een tijger."
 
Reply With Quote
 
Eric
Guest
Posts: n/a
 
      04-16-2007
On Apr 14, 4:10 am, "Dr.Ruud" <(E-Mail Removed)> wrote:
> Eric schreef:
>
> > For
> > clarity reasons, I didn't include all of the code.

>
>
>
> --
> Affijn, Ruud
>
> "Gewoon is een tijger."


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(EFAULT :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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Illegal seek with os.popen pruebauno@latinmail.com Python 4 06-04-2009 09:28 PM
When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write buffer? DR ASP .Net 2 07-29-2008 09:50 AM
When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write buffer? DR ASP .Net Building Controls 0 07-29-2008 01:37 AM
illegal seek smarty C Programming 16 05-16-2008 07:39 PM
illegal seek Dave Saville Perl Misc 21 09-17-2003 04:00 PM



Advertisments