- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Long command line and pstat_getproc()
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
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-06-2004 12:34 AM
тАО01-06-2004 12:34 AM
I need to get long (more than 128 chars) command lines out of pstat_getproc(). Currently pst_cmd is 64 bytes long and pst_ucomm is 17 bytes long.
I know It's possible as ps(1) does it in UNIX95 mode on the same machine.
What should I do?
Regards,
Mike
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-06-2004 03:10 AM
тАО01-06-2004 03:10 AM
Re: Long command line and pstat_getproc()
http://www.docs.hp.com./hpux/onlinedocs/B2355-60103/B2355-60103.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-06-2004 03:37 AM
тАО01-06-2004 03:37 AM
Re: Long command line and pstat_getproc()
2. I tried to use pstat_getcommandline() and link failed.
Any help?
Regards,
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-06-2004 05:23 AM
тАО01-06-2004 05:23 AM
Re: Long command line and pstat_getproc()
#include
#include
#include
char *getcommandline(int pid)
{
char command[500];
static char args[1024];
FILE *pipe;
int result;
char *newline;
sprintf(command, "UNIX95=1 /usr/bin/ps -p %d -x -o args=", pid);
pipe = popen(command, "r");
result = fread(args, 1, 1023, pipe);
pclose(pipe);
args[result] = 0;
newline = strchr(args, '\n');
if (newline) {
*newline = 0;
}
return args;
}
int main(int argc, char *argv[])
{
int i;
for (i=1; i
}
return 0;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-06-2004 05:28 AM
тАО01-06-2004 05:28 AM
Re: Long command line and pstat_getproc()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-06-2004 11:59 AM
тАО01-06-2004 11:59 AM
Solution#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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-06-2004 01:54 PM
тАО01-06-2004 01:54 PM
Re: Long command line and pstat_getproc()
Be sure that you pick a specific process or perhaps a user list. ps -e is a VERY expensive command to be used on a busy machine and may take longer than 1 second to run. If you need to monitor a specific process, use the PID and never use grep to locate processes.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-06-2004 11:17 PM
тАО01-06-2004 11:17 PM