![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Install Guide: Oracle Database 11g Release 1 on Oracle Enterprise Linux 5 | iBot | Oracle Updates (RSS) | 0 | 04-06-2008 06:10 AM |
| Upgrade Guide: Moving to Oracle RAC 11g on Oracle Enterprise Linux | iBot | Oracle Updates (RSS) | 0 | 04-06-2008 06:10 AM |
| Build Your Own Oracle RAC Cluster on Oracle Enterprise Linux and iSCSI | iBot | Oracle Updates (RSS) | 0 | 04-06-2008 06:10 AM |
| Install Oracle RAC 10g on Oracle Enterprise Linux using VMware Server | iBot | Oracle Updates (RSS) | 0 | 04-06-2008 06:10 AM |
| Oracle(R) University Launches Enterprise Linux Training and ... - CNNMoney.com | iBot | UNIX and Linux RSS News | 0 | 11-14-2007 10:00 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
vgscan produces no output using file descriptors on Oracle Enterprise Linux.
I wrote a simple program which will create a child process to execute a command and the output will be redirected to the file.
Please have a look at the following code -> #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <fcntl.h> void execute(char **argv) { pid_t pid; int status; int fStdOutDesc = open("/tmp/outfile", O_CREAT | O_RDWR, S_IREAD | S_IWRITE); int fStdErrDesc = open("/tmp/errfile", O_CREAT | O_RDWR, S_IREAD | S_IWRITE); printf("Out file Desc dup2 is %d\n",fStdOutDesc); printf("Err file Desc dup2 is %d\n",fStdErrDesc); if ((pid = fork()) < 0) /* fork a child process */ { printf("ERROR: forking child process failed...\n"); exit(1); } else if (pid == 0) /* for the child process: */ { dup2(fStdOutDesc, fileno(stdout)); dup2(fStdErrDesc, fileno(stderr)); if (execvp(*argv, argv) < 0) /* execute the command */ { printf("ERROR: exec failed...\n"); exit(1); } } else /* for the parent process: */ { while (wait(&status) != pid) ; /* wait for completion */ } } int main(void) { char cmd[1024]; char *argv[64]; printf("Enter the Command : "); scanf("%s",&cmd); /* works for ls & doesn’t work for vgscan */ printf("\n"); argv[0]=cmd; argv[1]='\0'; execute(argv); return 0; } After running above program, it will prompt for an input (command), if you enter “ls”, the output of the “ls” command is redirected to /tmp/outfile, whereas after entering vgscan, there will not be anything in either /tmp/outfile or /tmp/errfile. This problem is particularly with few commands like vgscan, pvscan, vgdisplay, lvdisplay etc whereas these commands give output if ran through shell. This is the case for only Oracle Enterprise Linux. The same program works fine on other Linux versions. Any help regarding this would be very much helpful. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|