- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- command "not found" exit code different when in an...
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
тАО02-04-2007 01:36 PM
тАО02-04-2007 01:36 PM
command "not found" exit code different when in an interactive shell
Interactively I get:
__________________
> CheckEnvironment.sh
sh: CheckEnvironment.sh: not found
> echo $?
127
__________________
But performing similar logic from within a script I get (with set -x on):
___script________
CheckEnvironment.sh $0 $File
if [ $? -ne 0 ]
___output________
+ CheckEnvironment.sh ./start_RMS_services.sh.in /tmp/start_RMS_services.sh.in.1028238.errors
/tmp/start_RMS_services.sh.in.1028238.sh[23]: CheckEnvironment.sh: not found
+ [ 0 -ne 0 ]
__________________
So how can I tell if a command is "not found" within a script?
(Note: I am hoping to whereis or which etc.)
- Tags:
- exit status
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2007 01:43 PM
тАО02-04-2007 01:43 PM
Re: command "not found" exit code different when in an interactive shell
(Note: I am hoping to avoid using whereis or which etc.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2007 01:52 PM
тАО02-04-2007 01:52 PM
Re: command "not found" exit code different when in an interactive shell
Which shell for the script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2007 03:05 PM
тАО02-04-2007 03:05 PM
Re: command "not found" exit code different when in an interactive shell
I worked it out.
My issue was that I was creating the script as an inline file and had neglected to escape the $0... which was of course 0 at the point when the script was being produced... so this code always passed the test:
________
CheckEnvironment.sh ./start_RMS_services.sh.in /tmp/start_RMS_services.sh.in.938148.errors
if [ 0 -ne 0 ]
then
________
I shall close this thread now to avoid embarrassing replies ;-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2007 03:07 PM
тАО02-04-2007 03:07 PM
Re: command "not found" exit code different when in an interactive shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-05-2007 02:40 PM
тАО02-05-2007 02:40 PM
Re: command "not found" exit code different when in an interactive shell
You may have to use "set +e" to turn off errexit when you do the whence in non-iteractive shells.
- Tags:
- whence