- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: system() call question
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
тАО03-31-2009 12:40 PM
тАО03-31-2009 12:40 PM
system() call question
int sts;
char *cmd = "mcr sys$system:tcpip$snmp_trapsnd.exe 0.0 local 0 0 0 -h 10.100.18.245 -v2c 1.3.6.1.6.3.1.1.4.1.0 \"D\" \"<
sts = system( cmd);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2009 12:58 PM
тАО03-31-2009 12:58 PM
Re: system() call question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2009 01:00 PM
тАО03-31-2009 01:00 PM
Re: system() call question
passing parameter question was never answered so I thought posting the question here since this is the relevant group .
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2009 01:07 PM
тАО03-31-2009 01:07 PM
Re: system() call question
I went back and looked at my post and here is what I wrote "
I fixed the issue as follows :
char *cmd = "mcr sys$system:tcpip$snmp_trapsnd.exe 0.0 local 0 0 0 -h 10.100.18.245 -v2c 1.3.6.1.6.3.1.1.4.1.0 \"D\" \"<
now my second problem ... i need to pass the message part as parameter .. how can I do this ? "
I didnt get any reply to this question ..where do you see the parameter passing way someone told me .. please point me to it.
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2009 01:57 PM
тАО03-31-2009 01:57 PM
Re: system() call question
Here are the important things to note:
1. The arguments argc and argv to the main function give you access to parameters on the command line.
2. Do not initialize cmd in your char statement as you insist on doing, just allocate space.
3. Use the sprintf function to load text into the cmd array that you previously allocated. The format is very similar to the printf statement, and those devious unix people included the letters "print" in the name, BUT IT DOES NOT PRINT ANYTHING, IT JUST PUTS TEXT INTO THE CMD ARRAY.
4. Use the debugger to see what happens to cmd before you pass it to the system() function.
Before Steven gave you a working example, several other answers in the same thread gave you all the information you needed make your own working example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2009 02:16 PM
тАО03-31-2009 02:16 PM
Re: system() call question
Here is an example of some C code that performs:
- system()
- sprintf()
- a DCL command
- C argument processing
It's extremely close to what you're asking for, but it's not an exact answer.
$ cc z
$ link z
$ z:==$sys$login:z
$ z USER
OpenVMS User Processes at 31-MAR-2009 17:04:44.44
Total number of users = ....
$ z TIME
31-MAR-2009 17:04:55
$ type z.c
#include
#include
main( int argc, char **argv ) {
char CmdBuffer[512];
sprintf( CmdBuffer, "SHOW %s", argv[1] );
system( CmdBuffer );
return 1;
}
$
I've posted up a very large C source code example (zip archive) at the HoffmanLabs site; the newuser source code package uses lib$spawn and argument processing and RMS and a whole lot more. Here are the current bits. A BSD-style license is in place.
http://64.223.189.234/node/1260
And FWIW, an update to this source code is underway. The new stuff uses argc and argv and getopt and various other features of OpenVMS. If you're interested in a preliminary copy, contact me offline.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2009 02:24 PM
тАО03-31-2009 02:24 PM
Re: system() call question
thanks for your help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2009 02:27 PM
тАО03-31-2009 02:27 PM
Re: system() call question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2009 02:49 PM
тАО03-31-2009 02:49 PM
Re: system() call question
A slightly updated version of the C code posted above is now posted at:
http://labs.hoffmanlabs.com/node/1261
If you're interested in learning C on your own, then one of the options is to borrow or to purchase the K&R C book Second Edition, or a similar book on the language.
http://en.wikipedia.org/wiki/The_C_Programming_Language_(book)
And also look at the C programming shelf available within the HP OpenVMS manuals. There are a gazillion C examples on the OpenVMS Freeware distributions, as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2009 04:20 PM
тАО04-01-2009 04:20 PM
Re: system() call question
#include
#include
#include
#define size 512
static char cmdbuffer[size];
main(int argc, char **argv )
{
int i;
int sts;
char *cmd = "mcr sys$system:tcpip$snmp_trapsnd.exe 0.0 local 0 0 0 -h 10.100.18.245 -v2c 1.3.6.1.6.3.1.1.4.1.0 \"D\"";
/* argv[0] is program name */
strncat (cmdbuffer, cmd,size);
strncat (cmdbuffer, " \"",size);
strncat (cmdbuffer, argv[1],size);
strncat (cmdbuffer,"\"",size);
printf ("%s\n",cmdbuffer);
sts = system(cmdbuffer);
printf( " sts = %%x%08x.\n", sts);
}
$ commarg "two parameters"
mcr sys$system:tcpip$snmp_trapsnd.exe 0.0 local 0 0 0 -h 10.100.18.245 -v2c 1.3.6.1.6.3.1.1.4.1.0 "D" "two parameters"
sts = %x00000001.