- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: system() command fails on HP-UX PARISC 11iv3
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
тАО04-06-2010 01:31 PM
тАО04-06-2010 01:31 PM
system() command fails on HP-UX PARISC 11iv3
when we execute system() command (as follows) in the application, it gives following error:
command syntax used in application code:
system ("ps -eaf | grep ssh");
error:
sh: ps: not found.
sh: grep: not found.
But if I test this with a sample program as:
#include
#include
int main()
{
system ("ps -eaf | grep ssh");
return 0;
}
It works fine.
Can anyone tell, what could be the reasons of the failure and why does it show different behavior?
NOTE: In application we are not doing any such operation which can disturb the shell environment.
Other Information:
------------------
# uname -a
HP-UX islrppss B.11.31 U 9000/800 936132380 unlimited-user license
# aCC -V
aCC: HP ANSI C++ B3910B A.03.80
- Tags:
- system
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2010 01:46 PM
тАО04-06-2010 01:46 PM
Re: system() command fails on HP-UX PARISC 11iv3
Apparently, system() is running "sh" as it
should, but "sh" is not finding "ps". I'd
guess that there's a problem with PATH in the
problem environment.
An easy (if not very portable) way out might
be to specify absolute paths to "ps" and
"grep" in your argument string.
To explore, you might throw in something
like:
system( "echo $PATH");
and see what that says.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2010 01:48 PM
тАО04-06-2010 01:48 PM
Re: system() command fails on HP-UX PARISC 11iv3
This suggests that your application's PATH doesn't contain '/usr/bin'.
You might fix your application to do"
# system ("/usr/bin/ps -eaf | grep /usr/bin/ssh");
...instead of:
# system ("ps -eaf | grep ssh");
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2010 02:25 PM
тАО04-06-2010 02:25 PM
Re: system() command fails on HP-UX PARISC 11iv3
That may not help it to find "grep", but it
could damage basic functionality. (If you've
seen one path, you've seen them all, I always
say.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2010 03:06 PM
тАО04-06-2010 03:06 PM
Re: system() command fails on HP-UX PARISC 11iv3
OK, stupid typo as Steven pointed out:
I wrote:
# system ("/usr/bin/ps -eaf | grep /usr/bin/ssh");
But should have written:
# system ("/usr/bin/ps -eaf | /usr/bin/grep /usr/bin/ssh");
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2010 03:37 PM
тАО04-06-2010 03:37 PM
Re: system() command fails on HP-UX PARISC 11iv3
As an optimization, you could toss that grep:
system("UNIX95=EXTENDED_PS /usr/bin/ps -af -C ssh")
Provided you don't care about -a exclusions.
Otherwise you might want to use: /usr/bin/grep -w ssh
- Tags:
- EXTENDED_PS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2010 03:48 PM
тАО04-06-2010 03:48 PM
Re: system() command fails on HP-UX PARISC 11iv3
Not every error is a typographical error.
> But should have written:
>
> # system ("/usr/bin/ps -eaf | /usr/bin/grep /usr/bin/ssh");
Why "/usr/bin/ssh" instead of "ssh"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2010 04:06 PM
тАО04-06-2010 04:06 PM
Re: system() command fails on HP-UX PARISC 11iv3
> Steven: Why "/usr/bin/ssh" instead of "ssh"?
OMG, I have failed to multitask during dinner :-( Yes, yes, I mean use *absolute* paths to your executables' only (although that should have been somewhat obvious from my *first* post's commentary (minus the bungled code corrected below):
# system ("/usr/bin/ps -eaf | /usr/bin/grep ssh");
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2010 02:53 AM
тАО04-07-2010 02:53 AM
Re: system() command fails on HP-UX PARISC 11iv3
Thanks for your reply.
yes, it works in the following way:
system("/usr/bin/ps -eaf|/usr/bin/grep ssh");
But I do not want to use in this way. It works fine on other platforms(Liux, Solaris) in the same way but not on HP.
As per your suggestion, I printed PATH before calling system() in the application code as:
system("echo $PATH");
system("ps -eaf|grep ssh");
PATH shows the correct output. It has all the required ones like:
/usr/ccs/bin:/usr/contrib/bin:/usr/contrib/Q4/bin:/opt/perl/bin:/usr/sbin:/usr/bin:/opt/ansic/bin:/usr/ccs/bin:/usr/contrib/bin:/usr/contrib/Q4/bin:/opt/perl/bin:/opt/ipf/bin:/opt/nettladm/bin:/opt/fcms/bin:/opt/wbem/bin:/opt/firefox:/opt/gnome/bin:.....
Then also the error occurs.
sh : ps : not found
sh : grep : not found
It would be highly appreciable if anyone can help me to find out the root cause of this failure.
Many Thanks in advance.
-Shikha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2010 06:59 AM
тАО04-07-2010 06:59 AM
Re: system() command fails on HP-UX PARISC 11iv3
You said it worked in a small example, so there is something special about your application.
>I printed PATH before calling system() in the application code as:
system("echo $PATH");
system("ps -eaf|grep ssh");
Hmm, that seems right.
>It has all the required ones like:
/usr/ccs/bin:/usr/contrib/bin:/usr/contrib/Q4/bin:/opt/perl/bin:/usr/sbin:/usr/bin:...
You may want to put /usr/bin first.
>It would be highly appreciable if anyone can help me to find out the root cause of this failure.
Unfortunately it seems you need to be looking for zebras. ;-)
You could use tusc to see what your application is doing with the environ(5):
tusc -fp -ea -o tusc.out application parms ...
And attach the resulting tusc.out if it isn't too big.
Otherwise look for sections doing fork/exec of /usr/bin/sh.
- Tags:
- zebras