0

Sorry, this is maybe a stupid question, but I am new to shell scripts.

I have a file called oem-device-name.sh. I need to execute an external check for Zabbix: https://www.zabbix.com/documentation/5.0/manual/config/items/itemtypes/external

The script itself is just 1 line, it is only an snmpget command:

snmpget -v 1 -c public -Oa -Ov -OQ 172.28.132.44:31161 BSS-RCP-MIB::oem-device-name.0

Wich Shebang should you recommend for my snmpget? And does it makes a difference if you write #!\bin\sh or #!\bin\bash in a .sh file.

1 Answer 1

1

#!/bin/sh uses whatever login shell the user currently has set. Most default to bash but this is not guaranteed

#!/bin/bash is used for (predictably) bash scripts

files with .sh suffix are somewhat deprecated and largely unnecessary - just name the script what you want without it

If you're using bash, use #!/bin/bash unless you foresee yourself (or other users) needing to run the script using a different shell (like csh)

2
  • Thank you for your answer. But if I look to the documentation from Zabbix (see link), I have to use the deprecated shell scripts. So I have to use #!/bin/sh ?
    – Jarne
    Commented May 4, 2020 at 7:58
  • Don't know about Zabbix. But in general you should be fine using #!/bin/sh and calling it script.sh
    – Peleion
    Commented May 4, 2020 at 12:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .