The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
I/O Redirec in Shell Code
Posted by: Matt D. | March 7, 2011 @ 4:02pm
C Code
[
Download
]
void executeCommand(char * fullCommandPath, char ** argumentatos, int argNum) { int fd = -1; int waitCheck = 0; if(strcmp(argumentatos[argNum],"&") != 0) { waitCheck = 1; } pid_t pid; pid = fork(); if(pid == 0) { /*if(strcmp(argumentatos[argNum - 1 - waitCheck],">") != 0) { close ( 1 ); fd = open(argumentatos[argNum - waitCheck], O_WRONLY | O_CREAT | O_TRUNC ); dup2(1, fd); } else if(strcmp(argumentatos[argNum - 1 - waitCheck],"<") != 0) { close ( 0 ); fd = open(argumentatos[argNum - waitCheck], O_RDONLY ); dup2(0, fd); } else if(strcmp(argumentatos[argNum - 1 - waitCheck],"+>") != 0) { close ( 1 ); fd = open(argumentatos[argNum - waitCheck], O_WRONLY | O_CREAT | O_APPEND); dup2(1, fd); }*/ execv(fullCommandPath, argumentatos); if(fd != -1) close(fd); exit(1); } else { if(waitCheck) wait(NULL); } }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.52 / 8
89 Votes
http://codebin.yi.org/1156
page generated in 0.00 seconds