Page 3 of 3 FirstFirst 123
Results 21 to 25 of 25

Thread: Detecting mount containing running script

  1. #21
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: Detecting mount containing running script

    No. Why should that be a problem? It's syntactically correct. The else branch just won't be reached in this case. Open a terminal and try something like:
    Code:
    (if true;then exit;else some garbage;fi)

  2. #22

    Unhappy Re: Detecting mount containing running script

    Quote Originally Posted by schragge View Post
    No. Why should that be a problem? It's syntactically correct. The else branch just won't be reached in this case. Open a terminal and try something like:
    Code:
    (if true;then exit;else some garbage;fi)
    Right, but how will you know if the "exec eject" command completed successfully? As soon as it's run, execution leaves the script and never returns again, so there is no way to check eject's exit code and to do something based on that.

  3. #23
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,172
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Detecting mount containing running script

    Quote Originally Posted by kiplingw View Post
    It would be nice if the script were not locking the device and control could return to the script after the eject command. But I guess that is not so straightforward.
    It's not the script that is locking the device...

    A different approach is to have your script self-copy to /var/tmp and then 'exec' the copy (maybe passing its original location as a parameter or environment variable). Then you are no longer using a file on the device.

  4. #24
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: Detecting mount containing running script

    +1 to what ofnuts said.
    There may be a problem if /var/tmp (or /tmp if you choose to use it instead) is mounted noexec. In this case, invoke it like
    Code:
    exec bash /var/tmp/$scriptname

  5. #25

    Re: Detecting mount containing running script

    Quote Originally Posted by schragge View Post
    +1 to what ofnuts said.
    There may be a problem if /var/tmp (or /tmp if you choose to use it instead) is mounted noexec. In this case, invoke it like
    Code:
    exec bash /var/tmp/$scriptname
    It's definitely possible to copy itself to tmp and execute the copy with the idea that it would relieve the device it was hosted on from being locked. I had considered that route, but then I figured it might not be worth the trouble and probably easier to just find a way to run the exec eject as the last command. But thanks for everyone's help.

Page 3 of 3 FirstFirst 123

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •