- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: best shell for writing a shell script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2006 10:27 AM
тАО01-22-2006 10:27 AM
Re: best shell for writing a shell script
Suppose a shell script written by someone is using #!/usr/bin/sh (which we can file by viewing the script) and my default shell is #!/usr/bin/ksh; do you suggest it is better to change my shell in #!/usr/bin/sh before executing that script ?
warm regards,
shiv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2006 12:05 PM
тАО01-22-2006 12:05 PM
Re: best shell for writing a shell script
You wrote: "Suppose a shell script written by someone is using #!/usr/bin/sh (which we can file by viewing the script) and my default shell is #!/usr/bin/ksh; do you suggest it is better to change my shell in #!/usr/bin/sh before executing that script ?"
There is no reason to change your default login shell, which you have defined in 'etc/passwd', for you account, to be the Korn shell.
When you run a Posix shell script, its instructions are interpreted by the Posix shell because you *specified* '/usr/bin/sh' as the interpreter in the first line of your script. This is correct form and will yield an execution consistent with the declared interpreter.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2006 02:54 PM
тАО01-22-2006 02:54 PM
Re: best shell for writing a shell script
You got all the answers from ITRC gurus. We always use /usr/bin/ksh n our shell scripts since we had to follow some coding standards. It varies across organisations, some prefer to use /sbin/sh since it will be available even in single user mode.
Hope this is clear.
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2006 07:14 PM
тАО01-22-2006 07:14 PM
Re: best shell for writing a shell script
i use 'sh' for all my scripts as well. there is not much it can not do, and well, if a scripts is to large i just switch to perl.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2006 07:23 PM
тАО01-22-2006 07:23 PM
Re: best shell for writing a shell script
When you are using in 3 or 5th run level then based on the requirement you can use ksh or sh or bash (if you are installed). It is better to go with ksh in hp-ux.
If you are not changing shell format in shell script then you will not get any error when executing ksh script in sh mode. Else it will prompt errors.
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2006 07:29 PM
тАО01-22-2006 07:29 PM
Re: best shell for writing a shell script
http://www.askdavetaylor.com/whats_acceptable_syntax_in_unix_and_linux_sh_scripts.html
Hope this link will be useful.
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2006 07:51 PM
тАО01-22-2006 07:51 PM
Re: best shell for writing a shell script
if you were to start writing your own script, i would agree with the comment above that it is preferrable that you start learning perl!
it is much more powerful
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2006 04:22 AM
тАО01-23-2006 04:22 AM
Re: best shell for writing a shell script
I prefer not to use CSH because nothing fits except C. KSH on UX or BASH on Linux is probably the best route to follow.
"#which ksh" will define where the interpreter sits.
A K-shell script may or may not work under bourne.. variables may need to be reset, via a sub shell.
- Tags:
- scummy C shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2006 04:35 AM
тАО01-23-2006 04:35 AM
Re: best shell for writing a shell script
That is the POSIX shell (on HPUX) and will work with KSH scripting standards.
I usually use #!/bin/sh less typing :)
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2006 05:11 AM
тАО01-23-2006 05:11 AM
Re: best shell for writing a shell script
It doesn't matter what your login shell is when you execute a script that has the 'she-bang' line at the top of the script. The script that you execute will always be run under the the shell listed in the 'she-bang'.
For example, I administer a number of sites where startup/install/configuration scripts for our software package are written in csh (ugh!). I use the POSIX shell (/usr/bin/sh) as my login shell, and when I execute one of those scripts, the subshell they execute in is csh.
If you ever edited the root crontab with crontab -e, you've noticed that when you file (:wq) it, a message is displayed:
warning: commands will be executed using /usr/bin/sh
This means that cron will use /usr/bin/sh to run the commands. However, if you are executing a script that has #!/usr/bin/csh as the first line of the script, it will spawn a csh subshell to execute the script in.
Cheers,
Mark
- « Previous
-
- 1
- 2
- Next »