how do collect shell output in a C program


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users how do collect shell output in a C program
# 1  
Old 12-30-2006
how do collect shell output in a C program

i use the system command to execute a shell command... ca i collect the out put in the form of a string or something using the same C program?
# 2  
Old 12-30-2006
Instead of doing it the way you are currently doing it, you should construct a pipe using popen.
# 3  
Old 12-31-2006
thanks

ya... i tried it out and got the results... thanks...
# 4  
Old 05-22-2009
Hi,

Can you please tell me how is this accomplished ?
# 5  
Old 05-25-2009
See 'man popen'.
# 6  
Old 05-25-2009
you will have more control with different streams using

Code:
use IPC::Open3;
open3(my $wfh, my $rfh, (my $efh = Symbol::gensym), $cmd);

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Not able ot collect perldoc output to a file

I need the output of perldoc command collected to a file # perldoc -l File::Scan::ClamAV > /usr/src/asas.txt No documentation found for "File::Scan::ClamAV". # cat /usr/src/asas.txt # (2 Replies)
Discussion started by: anil510
2 Replies

2. Shell Programming and Scripting

Passing multiple C program output into a shell

Hi I have the following C code # cat test.c #include <stdio.h> main() { printf ("The output is : Power\n"); printf ("The output is : No Power\n"); } The output of this C code is # ./test The output is : Power The output is : No Power Now i need to pass this outputs into a shell... (4 Replies)
Discussion started by: Priya Amaresh
4 Replies

3. UNIX for Dummies Questions & Answers

Shell script to collect inbound connections

Hi Kindly provide me shell script on server to collect inbound connections, using port number on Linux. (4 Replies)
Discussion started by: adminhelp
4 Replies

4. Shell Programming and Scripting

shell script to collect information from current and remote unix boxes

I am using AIX 5.3.0.0 ; I need a script to find out each remote AIX boxes Hostname, Model name and Serial number in following format Hostname Modelname SerialID AIXMC01 IBM,7026-B80 IBM,0110BBA1F AIXMC02 IBM,7026-H50 IBM,0110BBA56 AIXMC03 IBM,7026-H50 IBM,0110BBARR... (12 Replies)
Discussion started by: amir07
12 Replies

5. Programming

Please help me with my output for my program

Hello All, iam a new memeber today i joined this forum. hope i will get help. the below program takes input strings and give reverse of input string. && mv /home/test1/programs/display /home/test1/programs/old echo " Please enter the test " read a echo "$a" > file wc -c file > file1 perl... (1 Reply)
Discussion started by: ameyrk
1 Replies

6. Shell Programming and Scripting

Help me! Format output file using shell program

Hi, I have following input file. I want to generate output file in specific format using shell program. The input file has atleast few thousands of lines, the below are some sample lines. Input file: "ORDER NO"|"ORDER AMT"|"LINE ITEM"|"LINE AMT"|"SALES COMMISION %" ORD3456|5000|LIN345|30|25%... (8 Replies)
Discussion started by: dsubha
8 Replies

7. Programming

ambiguity in program output

1 #include <fcntl.h> 2 3 main(int argc, char *argv) 4 { 5 char buf; 6 int fd, count = 0; 7 8 if (argc > 1) 9 fd = open(argv, O_RDONLY); 10 else 11 fd = 0; /* Use standard input */ 12 13 while (read(fd, buf, 1) > 0) { 14 if (count < 5) write(1, buf, 1); 15 ... (3 Replies)
Discussion started by: bishweshwar
3 Replies

8. UNIX for Dummies Questions & Answers

Enable a shell to collect data from unix, return to windows

hi I am very new to UNIX. I need to retrieve data from a unix system and store it and display as output on a windows system. Initiation of procedure is through JAVASCRIPT-based buttons on a HTML page. This should cause a set of commands to run which colllect data from a unix based server and... (1 Reply)
Discussion started by: rossalyn_maxter
1 Replies

9. Programming

C program Output

The output I got for this pgm is "4 4 4 4". Can any one help me to understand how I got this output. Also please suggest me some links to learn about argumnets evaluation in C. # include <stdio.h> void func(int a, int b, int c, int d) { printf("%d %d %d %d", a, b, c, d); } int... (3 Replies)
Discussion started by: arunviswanath
3 Replies

10. UNIX for Dummies Questions & Answers

Capturing output from C++ program

Hi I have a C++ program that generates a lot of log information on the console, I need this output (printed using printf function) to go to a file since I will use crontab to schedule the job. I know I can do this: myprog > myfile but I don't know how to enter this in crontab. I use... (3 Replies)
Discussion started by: GMMike
3 Replies
Login or Register to Ask a Question