Operating System - Linux
1754109 Members
3628 Online
108811 Solutions
New Discussion юеВ

getting the command line argument in HPUX 11.11

 
S N Raju
Advisor

getting the command line argument in HPUX 11.11

Hi all,

I have HPUX 11.0 box.
if i compile the snippet on HPUX 11.0 box

#include
#include
#define MAX_LENGTH (1024)
main (argc, argv) int argc; char *argv[]; {
int pid;
char long_command [MAX_LENGTH];
union pstun pu;

pid = atoi(argv[1]);
pu.pst_command = long_command;
if (pstat(PSTAT_GETCOMMANDLINE, pu, MAX_LENGTH, 1, pid) == -1) {
printf("ERROR: pstat() failure using pid(%d)\n", pid);
exit(-1);
}
printf("pid %d = %s\n", pid, pu.pst_command);
}


I got the error :Undeclared variable 'PSTAT_GETCOMMANDLINE'.

for succesful compilation do i need to compile it on only HPUX11.11 and above..

or am i missing any declaration..

can someone help me on this...

Thank u all
raju
10 REPLIES 10
Steven E. Protter
Exalted Contributor

Re: getting the command line argument in HPUX 11.11

Shalom Raju,

What compiler are we talking about?

Seems that simple code like this should work. Add a printf statement after this:
pid = atoi(argv[1]);

I'd like to see what we're getting and narrow down the part of the code that is causing the error.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: getting the command line argument in HPUX 11.11

Hi Raju:

For starters, the header file '/usr/include/sys/pstat/pstat_ops.h' doesn't appear on my 11.0 box. As I recall, there was extensive work on the 'pstat' interface that occured in 11.11, so I think that you are going to have to redraft your code to compile it on 11.0.

Regards!

...JRF...
HGN
Honored Contributor

Re: getting the command line argument in HPUX 11.11

Hi

If you think issue is resolved, you can assign points and close this thread.
Your feedback shows 0 out of 14 responses,hope you appreacite that people spend their valuable time helping out and the best way to show gratitude is by assigning points.

Rgds

HGN
S N Raju
Advisor

Re: getting the command line argument in HPUX 11.11


Hi All,

The error i am facing is compile time error and not runtime error.Is PSTAT_GETCOMMANDLINE is a pre-defined variable in HPUX or need to include any header file.I want to know whether PSTAT_GETCOMMANDLINE has been introduced newly in HPUX 11.11..since i am compiling on HPUX 11.0 box. The compiler i am using is C++ compiler and version is HPUX 11.0..

Thank u all
Raj
Peter Godron
Honored Contributor

Re: getting the command line argument in HPUX 11.11

Raju,
I have compiled your code, as is, on my 11.11 box without problems using gcc.
OldSchool
Honored Contributor

Re: getting the command line argument in HPUX 11.11

"man pstat" on 11.0 doesn't list that option
Michal Toth
Regular Advisor

Re: getting the command line argument in HPUX 11.11

you need 11iV1 to get this working
Sandman!
Honored Contributor

Re: getting the command line argument in HPUX 11.11

Hi Raj,

It'll work on 11.0 with some modifications. The PSTAT_GETCOMMANDLINE variable is undefined since file is not present. You have to initialize it to a value that is not used by the kernel or look at its value on an 11i system in the file. Here's the version that works on an 11.0 system.


#include
#define MAX_LENGTH (1024)

main (argc, argv) int argc; char *argv[]; {
int pid, PSTAT_GETCOMMANDLINE = 34;
char long_command [MAX_LENGTH];
union pstun pu;

pid = atoi(argv[1]);
pu.pst_command = long_command;
if (pstat(PSTAT_GETCOMMANDLINE, pu, MAX_LENGTH, 1, pid) == -1) {
printf("ERROR: pstat() failure using pid(%d)\n", pid);
exit(-1);
}
printf("pid %d = %s\n", pid, pu.pst_command);
}
S N Raju
Advisor

Re: getting the command line argument in HPUX 11.11


Hi sandman ,

I was able to compile successfully in HPUX 11.0
box.Thank u all for all ur help and support.

thanks
raju