- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- running shell scrit form C++
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
Forums
Discussions
Discussions
Discussions
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
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
05-19-2006 04:34 AM
05-19-2006 04:34 AM
running shell scrit form C++
I have to run a shell scipt form my C++ file and get the output obtained by running the script in my cpp file.
Can any one throw some light as to how to do this
Thanks in advance
regards
Binu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2006 04:46 AM
05-19-2006 04:46 AM
Re: running shell scrit form C++
Have you tried using "system()" call ? I think, it should be helpful to you
-Arun
- Tags:
- system
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2006 05:29 AM
05-19-2006 05:29 AM
Re: running shell scrit form C++
- Tags:
- popen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2006 05:57 AM
05-19-2006 05:57 AM
Re: running shell scrit form C++
#!/usr/bin/sh
(or ksh or csh or perl....whatever)
Without that line, there is no way to know how to run the script (scripts always require an interpreter, typically a shell or scripting language amd the C program is not a shell)
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2006 06:38 AM
05-19-2006 06:38 AM
Re: running shell scrit form C++
You can use "sprintf" function
eg.
(void)sprintf(cmd, "cat /proc/iomem 2>/dev/null", idedb[i].device);
and you can use "popen" function
if ((fp = (FILE *)popen("cat /proc/iomem 2>/dev/null", "r")) == NULL) {
error ("popen failed when trying to view iomem data");
return (1);
}
http://www.phim.unibe.ch/comp_doc/c_manual/C/FUNCTIONS/popen.html
Regards,
Sung
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2006 03:04 PM
05-19-2006 03:04 PM
Re: running shell scrit form C++
(void)sprintf(cmd, "cat /proc/iomem 2>/dev/null", idedb[i].device);
The sprintf command by itself will do nothing except build the string "cmd" that might later be used in a system(cmd) function or a popen(cmd,"r").
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2006 01:54 AM
05-25-2006 01:54 AM