Run shell script from C program by calling fork and execl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Run shell script from C program by calling fork and execl
# 1  
Old 12-01-2009
Run shell script from C program by calling fork and execl

I need to write a c program that uses the fork and excel system calls to run the shell script mode invoked like this: "./mode 644 ls -l" (that is the argumetns will always be 644 ls -l)

here's the mode script:
Code:
#!/bin/sh
octal="$1"
shift
find . -maxdepth 1 -perm $octal -exec $@ {} \;

here's my c program:
Code:
        int rv;
        rv = execl("mode","644","ls","-l");
        getchar();

I don't get how to use fork and excel really?

Last edited by pludi; 12-01-2009 at 03:21 AM..
# 2  
Old 12-01-2009
Homework?
# 3  
Old 12-01-2009
yesSmilie
I really do learn from the responses so I don't feel too bad about asking
# 4  
Old 12-01-2009
Be as that might, but for homework there's an extra forum set aside, with additional rules. Pay special attention to the red text at the bottom of the rules, and then repost there.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script run curl command calling cyber-Ark RESTAPI

Hi All, We have a requirement to Integrate Cyber-Ark with Informatica . Basically cyberark will contain the username and password for Database. First step will be 1)In shell Script run curl command calling cyber-Ark RESTAPI requesting the credentials and store the secret in a variable. ... (0 Replies)
Discussion started by: Praveena9102
0 Replies

2. Shell Programming and Scripting

Perl program to run a Shell script issues...

Hi all, I have the following Perl script which is intended to run a Shell script and generate some logging for the purposes of tracking weather or not the script ran. I get an error, of course, since I don't know what I'm doing really. Here is the code: #!/opt/perl/bin/perl -w ... (14 Replies)
Discussion started by: zixzix01
14 Replies

3. Shell Programming and Scripting

Shell script to run a python program on multiple entries in a file

Hello I am trying to run a python program using shell script, which takes a single argument from a file. This file has one entry per line : 1aaa 2bbb 3ccc 4ddd 5eee ... ... ... My shell script runs the program, only for the last entry : #!/bin/sh IFS=$'\n' for line in $(cat... (2 Replies)
Discussion started by: ad23
2 Replies

4. Shell Programming and Scripting

Calling perl script in shell program

How to call a perl script in shell program / shell scripting. PLS HELP ME (2 Replies)
Discussion started by: hravisankar
2 Replies

5. Programming

Calling a shell script from a C program

Hi, I have a shell script which connects to a database and fetches the count of the records from a table. I want to embed this whole script in a C program. Also the count fetched should be available in the C program for further usage. Please let me know how this can be done. Thanks (9 Replies)
Discussion started by: swasid
9 Replies

6. Shell Programming and Scripting

Calling a shell script from a C program

Hi, I have a shell script which connects to a database and fetches the count of the records from a table. I want to embed this whole script in a C program. Also the count fetched should be available in the C program for further usage. Please let me know how this can be done. Thanks ... (0 Replies)
Discussion started by: swasid
0 Replies

7. Shell Programming and Scripting

calling a program (w/ params) from within shell

Hi all, I need to call some script (s1) from within my shell script (s2). s1 accepts parameters and I want to feed it with values of params from my script. I tried many things but none work (I am so much of a beginner), please help one of my attempts : . . . param1="hehe" param2="haha" ... (12 Replies)
Discussion started by: Lorna
12 Replies

8. Shell Programming and Scripting

Calling Functions of Other K Shell Program

Hi, I have a K shell a.ksh function abc { // Some logic } In b.ksh i have included the a.ksh ./a.ksh I want to call the abc function from this b.ksh script. Thanks Vijay (2 Replies)
Discussion started by: vijaykrc
2 Replies

9. Shell Programming and Scripting

want to run different files under the same program using shell script

suppose have different files 1.1 2.2 3.3 4.4 5.5 All the files have to run under the same command say tr -d '\n' so how to run all the files under the same command by using shell script (3 Replies)
Discussion started by: cdfd123
3 Replies

10. Shell Programming and Scripting

Calling SHELL script from C program

Hi, I just tried to call a simple script from a pretty simple C program. I could not succeed :-( a message was thrown saying "sh: line 1: "Script name with path": Permission denied" The C program and shell script are below, both are in the same directory and shell script is given... (7 Replies)
Discussion started by: Chanakya.m
7 Replies
Login or Register to Ask a Question