![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C program to execute shell script | baigmd | Shell Programming and Scripting | 2 | 3 Weeks Ago 03:08 AM |
| How to execute a program at expect script | fozay | Shell Programming and Scripting | 6 | 07-10-2009 04:10 AM |
| Script to open program and send/execute command in program | tuathan | UNIX for Dummies Questions & Answers | 1 | 11-19-2008 09:59 PM |
| How to execute shell Script? | siva | Shell Programming and Scripting | 3 | 05-14-2002 11:07 AM |
| Urgent!! How to write a shell program to execute command to access internet? | firebirdonfire | UNIX for Dummies Questions & Answers | 2 | 04-26-2001 11:16 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
C program to execute Shell script with arguments
Hi,
Can anyone help with the below code. I am trying to execute Shell script with arguments in C program but it is giving errors. Code:
#include <stdlib.h>
#include <stdio.h>
int main (int argc, char *argv[])
{
int count;
for (count = 1; count < argc; count++)
{
return system("/tmp/lab5.sh ", argv[count]);
}
return 0;
}
Last edited by pludi; 3 Weeks Ago at 02:24 AM.. Reason: code tags, please... |
|
|||||
|
C program to execute script
In C++, you can:
Code:
#include <stdlib.h>
#include <stdio.h>
#include <string>
int main (int argc, char *argv[])
{
int count;
std::string cadena = "";
std::string orden;
for (count = 1; count < argc; count++)
{
cadena.append (argv[count]);
}
orden = "/tmp/lab5.sh " + cadena;
return system(orden.c_str());
}
Last edited by fpmurphy; 3 Weeks Ago at 08:20 AM.. Reason: code tags added |
|
||||
|
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|