Results 1 to 9 of 9

Thread: Shell execution on FAT32?

  1. #1

    Default Shell execution on FAT32?

    Is it possible to somehow execute shell scripts on FAT32 file system? Like, I need to run this script on the FAT32 drive, and it gives me a bad interpreter: permission denied error. Moving all the files to an Ext3 would be hard as I have one huge FAT32 for all programs, documents etc., although possible.

  2. #2
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: Shell execution on FAT32?

    The problem is generally not the FAT filesystem per se, but that usually files edited with a DOS/Windows editor have CR-NL line endings instead of the usual NL only Unix/Linux line ending. This gives rise to the bad interpreter error as what you are attempting to execute is literally /bin/sh^M (where ^M stands for a control-M). Fix this at the editor level (vim allows you to set the file format) or convert the files.

    Even if you try to get around this by doing:

    Code:
    sh script.sh
    the ^M on the other lines will mess up things.

  3. #3
    ab@novell.com NNTP User

    Default Re: Shell execution on FAT32?

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    There is also a dos2unix command you can run against a file that will
    convert the line endings nicely for you.

    Good luck.





    ken yap wrote:
    > The problem is generally not the FAT filesystem per se, but that usually
    > files edited with a DOS/Windows editor have CR-NL line endings instead
    > of the usual NL only Unix/Linux line ending. This gives rise to the bad
    > interpreter error as what you are attempting to execute is literally
    > /bin/sh^M (where ^M stands for a control-M). Fix this at the editor
    > level (vim allows you to set the file format) or convert the files.
    >
    > Even if you try to get around this by doing:
    >
    >
    > Code:
    > --------------------
    > sh script.sh
    > --------------------
    >
    >
    > the ^M on the other lines will mess up things.
    >
    >

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFIxAi73s42bA80+9kRAnUJAJ48X+MtUzQz+Jd4/UnV6Sq05lJdFQCfacXu
    z3SqfEYyNY8aJIM1zxCa+iE=
    =dLXm
    -----END PGP SIGNATURE-----

  4. #4
    Rikishi42 NNTP User

    Default Re: Shell execution on FAT32?

    On 2008-09-07, GreatEmerald <GreatEmerald@no-mx.forums.opensuse.org> wrote:

    > Is it possible to somehow execute shell scripts on FAT32 file system?
    > Like, I need to run 'this script' (http://pastebin.com/m6441c3a2) on the
    > FAT32 drive, and it gives me a bad interpreter: permission denied error.
    > Moving all the files to an Ext3 would be hard as I have one huge FAT32
    > for all programs, documents etc., although possible.


    Assuming the problem is *not* the EOL character, as you don't mension it...

    The only "problem" with running scripts from a FAT partition is that you
    can't set them "executable". But for that, the solution is allready given.
    Just specify the name of the shell before the scripts name:
    bash 'this script' or
    sh 'this script' for instance.



    If you want to avoid having to type that, you can also configure mc
    (Midnight Commander) to launch the script with the shell, based on the file
    extension.

    I did this to run python scripts from a Windows drive. When I'd hit <enter>
    on a *.py file, mc would run python with that file.
    (works from whatever kind of partition, as long as you can read the file)



    --
    Hanlon's Razor:
    Never attribute to malice that which is
    adequately explained by stupidity.

  5. #5

    Default Re: Shell execution on FAT32?

    I made the script by a copy-paste to KWrite. That messes it too? And do I need anything else than Bash for the dos2unix command, and what's the syntax? "# dos2unix filename"?

  6. #6
    Rikishi42 NNTP User

    Default Re: Shell execution on FAT32?

    On 2008-09-07, GreatEmerald <GreatEmerald@no-mx.forums.opensuse.org> wrote:

    > I made the script by a copy-paste to KWrite. That messes it too? And do
    > I need anything else than Bash for the dos2unix command, and what's the
    > syntax? "# dos2unix filename"?


    If you wrote them with kwrite, just run them. It's extremely unlikely you'd
    have any problems.


    --
    Hanlon's Razor:
    Never attribute to malice that which is
    adequately explained by stupidity.

  7. #7

    Default Re: Shell execution on FAT32?

    I tried that, and like I said, I get the bad interpreter permission denied error. There is no new line at the end, not sure if there's any difference there. And as this script basically makes it run the ut2004-bin program, I tried opening it directly, no luck. Permission denied, even if I try to do that as root!

  8. #8
    ab@novell.com NNTP User

    Default Re: Shell execution on FAT32?

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Yup.... that's it.

    Try the following:

    /bin/bash /path/to/your/script

    Good luck.





    GreatEmerald wrote:
    > I made the script by a copy-paste to KWrite. That messes it too? And do
    > I need anything else than Bash for the dos2unix command, and what's the
    > syntax? "# dos2unix filename"?
    >
    >

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFIxWMR3s42bA80+9kRAgZiAJoDE4Bs92bM+Xd7NYdktoXsDaE3VACghyEB
    Ql5G4RZVfWMkHXUZCjQmAPc=
    =sLW8
    -----END PGP SIGNATURE-----

  9. #9

    Default Re: Shell execution on FAT32?

    Yes! It works! Thanks!
    Now how do I make that into a symlink in /usr/bin so I could start it by just typing in ut2004? Or will I have to always type /bin/bash ut2004?

Posting Permissions

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