Illegal seek

Discussion in 'Perl Misc' started by Eric, Apr 13, 2007.

  1. Eric

    Eric Guest

    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
    Eric, Apr 13, 2007
    #1
    1. Advertising

  2. Eric

    Uri Guttman Guest

    >>>>> "E" == Eric <> 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.stemsystems.com
    --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
    Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
    Uri Guttman, Apr 13, 2007
    #2
    1. Advertising

  3. Eric

    Eric Guest

    On Apr 13, 2:24 pm, Uri Guttman <> wrote:
    > >>>>> "E" == Eric <> 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.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
    Eric, Apr 13, 2007
    #3
  4. 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
    John W. Krahn, Apr 14, 2007
    #4
  5. Uri Guttman wrote:
    >>>>>>"E" == Eric <> 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
    John W. Krahn, Apr 14, 2007
    #5
  6. Eric

    Uri Guttman Guest

    >>>>> "JWK" == John W Krahn <> writes:

    JWK> Uri Guttman wrote:
    >>>>>>> "E" == Eric <> 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 ------ -------- http://www.stemsystems.com
    --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
    Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
    Uri Guttman, Apr 14, 2007
    #6
  7. Eric

    Dr.Ruud Guest

    Eric schreef:

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


    :(

    --
    Affijn, Ruud

    "Gewoon is een tijger."
    Dr.Ruud, Apr 14, 2007
    #7
  8. Eric

    Eric Guest

    On Apr 14, 4:10 am, "Dr.Ruud" <> 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:)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
    Eric, Apr 16, 2007
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. smarty

    illegal seek

    smarty, May 14, 2008, in forum: C Programming
    Replies:
    16
    Views:
    5,038
    Keith Thompson
    May 16, 2008
  2. Replies:
    4
    Views:
    1,067
  3. Dave Saville

    illegal seek

    Dave Saville, Sep 8, 2003, in forum: Perl Misc
    Replies:
    21
    Views:
    276
    Alan J. Flavell
    Sep 17, 2003
  4. Illegal Seek - Any Hints

    , Apr 4, 2005, in forum: Perl Misc
    Replies:
    3
    Views:
    134
  5. Replies:
    3
    Views:
    123
    Andreas Perstinger
    May 14, 2013
Loading...

Share This Page