Sponsored Content
Full Discussion: [C] execl and pipes?
Top Forums Programming [C] execl and pipes? Post 302584705 by Corona688 on Saturday 24th of December 2011 05:02:57 PM
Old 12-24-2011
Code:
if ((PID1=fork())==0) { // child
    close(fd[0]);
    dup2(fd[1],STDOUT_FILENO)
    close(fd[1]); // close ALL loose ends!
    execl("~/Escritorio/SO/todos-P-Modulo2-Sesion4/esclavo","2","10");    // I open the slave program   
} else {

Quote:
Originally Posted by lamachejo
I don't know how to send the data to the pipes in the execl program.
If you want to send data to esclavo's standard input, you will need another pipe.

If you want to read data from esclavo's standard output, read() from the read-end of the pipe in the parent.

You don't need declare anything or do anything special in the esclavo program itself. It can just read standard input and write to standard output as usual. By overriding the value of stdout with dup2(), you will cause esclavo to write to the pipe whenever it writes to standard output.

Otherwise, I don't understand your question.
This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Programming

execl, execv or execp

Hi! I'm writing a C program which gets from the command line a shell command (such as "ls" ) and I should execute it. My Q is: how can I send a command to the shell? I know I have to use one of the above functions, but I don't know how to use them. Thanks eyal (1 Reply)
Discussion started by: azran
1 Replies

2. Filesystems, Disks and Memory

PIPEs and Named PIPEs (FIFO) Buffer size

Hello! How I can increase or decrease predefined pipe buffer size? System FreeBSD 4.9 and RedHat Linux 9.0 Thanks! (1 Reply)
Discussion started by: Jus
1 Replies

3. Programming

execl / execv ?

Hi, Is it possible to run a program from my C program using only the full pathname? for example if I wanna call: "ls", so I whould have to use: execl("/bin/ls", "ls", NULL); Is it possible to do this using only: "/bin/ls" thanks (1 Reply)
Discussion started by: owijust
1 Replies

4. Programming

execl()

can anyone explain how to pass arguments of a program in execl function pls explain with a sample code. (2 Replies)
Discussion started by: bankpro
2 Replies

5. Shell Programming and Scripting

need help with execl command

I want to make simultanous sh commands in an exec command for example I want to counts the lines in a file wc -l my file.txt | awk -F" " '{print $1}'` works fine in sh but I want to implement it in a c code the first part works like this execl("/usr/bin/wc", "wc", "-l", "myfile.txt",... (1 Reply)
Discussion started by: walnut
1 Replies

6. Programming

execl function at GDB

Hi, we would appreciate if any one answer the below query. void main() { printf(“ I am in main\n”); execl(“/HOME/source/file2”,” /HOME/source/file2”,1,0); printf(“after execl\n”); } How to step the file2 source code in GDB. (2 Replies)
Discussion started by: RAMESHPRABUDASS
2 Replies

7. Programming

time execl

hello everybody how can i time the execution of execl() command inside my C code? for example, i wrote.. execl("md5sum","md5sum","myprog",NULL); i want to count the duration of the execl command! thanx in advance! (2 Replies)
Discussion started by: nicos
2 Replies

8. Red Hat

execl command

how to use find command in execl function, I used: execl("/usr/bin/find","find","~","-name","filename.c",0); but it shows find: ~ no file and directory i need to get the path of the file from the home .:wall: (2 Replies)
Discussion started by: Mahendravarma
2 Replies

9. Programming

When execl fails in C

when execl fails using the command lss, it doesnt go into the next line execl("/bin/sh", "/bin/sh", "-c", command, NULL); perror("execl failed"); exit(127); for some reason the child process just stops and also the parent process also stops so the line after the line that... (3 Replies)
Discussion started by: omega666
3 Replies

10. UNIX for Beginners Questions & Answers

Execl() command

Hi, If I write in a c file : execlp("date","date",NULL); printf("A\n"); And then run through the terminal would "A" be printed ? I understood that execlp will exit the program after it finished so the next lines of code won`t be executed afterwards.. Is that true ? (1 Reply)
Discussion started by: uniran
1 Replies
ADV(4)							   BSD Kernel Interfaces Manual 						    ADV(4)

NAME
adv -- ConnectCom Solutions AdvanSys SCSI adapter driver SYNOPSIS
adv* at pci? dev ? function ? adv0 at isa? port ? irq ? drq ? adv* at cardbus? function ? scsibus* at adv? DESCRIPTION
The adv driver supports the following AdvanSys SCSI host adapters PCI bus Connectivity Products: ABP920 Bus-Master PCI (16 CDB) ABP930 Bus-Master PCI (16 CDB) (note 1) ABP930U Bus-Master PCI Ultra (16 CDB) ABP930UA Bus-Master PCI Ultra (16 CDB) ABP960 Bus-Master PCI MAC/PC (16 CDB) (note 2) ABP960U Bus-Master PCI MAC/PC Ultra (16 CDB) (note 2) Notes: 1. This board has been sold by SIIG as the Fast SCSI Pro PCI. 2. This board has been sold by Iomega as a Jaz Jet PCI adapter. Single Channel Products: ABP940 Bus-Master PCI (240 CDB) ABP940U Bus-Master PCI Ultra (240 CDB) ABP970 Bus-Master PCI MAC/PC (240 CDB) ABP970U Bus-Master PCI MAC/PC Ultra (240 CDB) ABP940UW Bus-Master PCI Ultra-Wide (240 CDB) Multi Channel Products: ABP950 Dual Channel Bus-Master PCI (240 CDB Per Channel) ABP980 Four Channel Bus-Master PCI (240 CDB Per Channel) ABP980U Four Channel Bus-Master PCI Ultra (240 CDB Per Channel) ISA bus Connectivity Products: ABP510/5150 Bus-Master ISA (240 CDB) (note 1) ABP5140 Bus-Master ISA (16 CDB) (note 1) (note 2) ABP5142 Bus-Master ISA with floppy (16 CDB) (note 3) Notes: 1. This board has been shipped by HP with the 4020i CD-R drive. The board has no BIOS so it cannot control a boot device, but it can con- trol any secondary SCSI device. 2. This board has been sold by SIIG as the i540 SpeedMaster. 3. This board has been sold by SIIG as the i542 SpeedMaster. Single Channel Products: ABP542 Bus-Master ISA with floppy (240 CDB) ABP842 Bus-Master VL (240 CDB) Dual Channel Products: ABP852 Dual Channel Bus-Master VL (240 CDB Per Channel) SEE ALSO
cd(4), ch(4), intro(4), isa(4), pci(4), scsi(4), sd(4), st(4) http://www.connectcom.net/ http://www.siig.com/ HISTORY
The adv device driver appeared in NetBSD 1.4. AUTHORS
Baldassare Dante Profeta <dante@mclink.it> BSD
June 4, 1999 BSD
All times are GMT -4. The time now is 12:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy