Jump to content


Photo
- - - - -

Dear linux script writer


  • Please log in to reply
9 replies to this topic

#1 SigFLUP

SigFLUP

    SUPR3M3 31337 Mack Daddy P1MP

  • Members
  • 367 posts
  • Gender:Not Telling

Posted 29 December 2009 - 04:11 PM

Dear linux script writer,

Unless your script needs it don't start with #!/bin/bash . Not every unix has bash by default (for example, openbsd). Want you want to start with is #!/bin/sh

Thank you for your time and consideration


edit: maybe that sounds a little harsh, i was a little angry when I wrote that.. still use /bin/sh mate

Edited by SigFLUP, 29 December 2009 - 04:52 PM.


#2 BinaryLust

BinaryLust

    SCRiPT KiDDie

  • Members
  • 23 posts
  • Gender:Female

Posted 29 December 2009 - 07:43 PM

Prejudice is a bitch.

Just don't assume, get to know and then be an ass.

#3 livinded

livinded

    Dangerous free thinker

  • Agents of the Revolution
  • 1,942 posts
  • Location:~/

Posted 01 January 2010 - 02:43 PM

You probably shouldn't use use the direct path to the interpreter and should use environment since many of the BSDs and UNIXs install stuff in different places than linux.

#4 SigFLUP

SigFLUP

    SUPR3M3 31337 Mack Daddy P1MP

  • Members
  • 367 posts
  • Gender:Not Telling

Posted 01 January 2010 - 04:25 PM

You probably shouldn't use use the direct path to the interpreter and should use environment since many of the BSDs and UNIXs install stuff in different places than linux.


I'm not entirely sure if you can use environment variables in the interpreter line. I'm pretty sure you can't. If you have file u containing

#!$UU
echo "hello"


and we

$ export UU=/bin/sh
$ ./u

we get

/bin/ksh: ./u: No such file or directory

so it looks like we have to specify a direct path. I've seen no interpreter scripts without a direct path in the interpreter line, myself

does anyone know if having /bin/sh is posix?

Edited by SigFLUP, 01 January 2010 - 04:26 PM.


#5 livinded

livinded

    Dangerous free thinker

  • Agents of the Revolution
  • 1,942 posts
  • Location:~/

Posted 01 January 2010 - 09:28 PM

no, I mean actually using the environment binary. #!/usr/bin/env sh, bash, ruby, python, perl, php, etc.

#6 SigFLUP

SigFLUP

    SUPR3M3 31337 Mack Daddy P1MP

  • Members
  • 367 posts
  • Gender:Not Telling

Posted 01 January 2010 - 10:15 PM

no, I mean actually using the environment binary. #!/usr/bin/env sh, bash, ruby, python, perl, php, etc.


oh neat, I didn't know about env. cool- thanks!

#7 livinded

livinded

    Dangerous free thinker

  • Agents of the Revolution
  • 1,942 posts
  • Location:~/

Posted 02 January 2010 - 03:02 PM

env is fairly common and should exist on any modern unix like operating system as well as the old ones. It should be able to resolve the path for any of the interpreters you have installed.

#8 frogbong

frogbong

    mad 1337

  • Members
  • 134 posts
  • Country:
  • Gender:Male

Posted 02 January 2010 - 05:33 PM

Who cares what's in the script as long as it runs. I've never had any problems running scripts because every operating system I've used knows how to deal with .sh extensions. Good rule of thumb: if it does what it's supposed to do, hooray; if not.. you f**ked up kid, and you better figure out how to fix it.

#9 SigFLUP

SigFLUP

    SUPR3M3 31337 Mack Daddy P1MP

  • Members
  • 367 posts
  • Gender:Not Telling

Posted 02 January 2010 - 06:25 PM

Who cares what's in the script as long as it runs. I've never had any problems running scripts because every operating system I've used knows how to deal with .sh extensions. Good rule of thumb: if it does what it's supposed to do, hooray; if not.. you f**ked up kid, and you better figure out how to fix it.


I've had this problem in the past. Usually it's a perl script where they assume perl someplace else. Every so often it's because they assume I have bash, so then I either have to go install it for them or change their script.

#10 frogbong

frogbong

    mad 1337

  • Members
  • 134 posts
  • Country:
  • Gender:Male

Posted 03 January 2010 - 12:26 PM


Who cares what's in the script as long as it runs. I've never had any problems running scripts because every operating system I've used knows how to deal with .sh extensions. Good rule of thumb: if it does what it's supposed to do, hooray; if not.. you f**ked up kid, and you better figure out how to fix it.


I've had this problem in the past. Usually it's a perl script where they assume perl someplace else. Every so often it's because they assume I have bash, so then I either have to go install it for them or change their script.


I see; sounds like a Unix-related problem. It's like when you find some code/script that's missing small amounts of syntax or declarations. Typical today though; especially if you're on the avenue of security looking for tools or exploits.




BinRev is hosted by the great people at Lunarpages!