Sponsored Content
Operating Systems Linux vgscan produces no output using file descriptors on Oracle Enterprise Linux. Post 302173624 by sandiworld on Friday 7th of March 2008 09:38:31 AM
Old 03-07-2008
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.
 

4 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

in Oracle Enterprise Linux not able to redirect pvscan output

hi, In Oracle Enterprise Linux I'm not able to redirect output of commands pvscan and vgscan into a file. File is coming blank Please suggest something Thanx. (1 Reply)
Discussion started by: discover
1 Replies

2. Linux

In Oracle Enterprise Linux, not able redirect pvscan output

Hi, I'm not able to redirect output of ovscan and vgscan commands to a file in Oracle Enterprise Linux. Please suggest something. Thanks Mayank (1 Reply)
Discussion started by: discover
1 Replies

3. UNIX for Dummies Questions & Answers

linux sort command produces strange output

cat a .a ba .b bb .c bc sort a .a .b ba bb bc .c NOTE: .a and .b appears before ba and bb, where as .c appears after bc. In general (3 Replies)
Discussion started by: ajb
3 Replies

4. UNIX for Advanced & Expert Users

Linux fdisk question (Oracle Enterprise Linux)

OS: Oracle Enterprise Linux 6.2 Hypervisor: VMWare workstation 9 I created a VM and attached a 7gb virtual disk to it. Using fdisk , I partioned the disk like below. The filesystems mounted on this is working fine. But I am seeing the message Partition n does not end on cylinder boundary.... (2 Replies)
Discussion started by: kraljic
2 Replies
Jifty::DBI::Handle::Oracle(3pm) 			User Contributed Perl Documentation			   Jifty::DBI::Handle::Oracle(3pm)

NAME
Jifty::DBI::Handle::Oracle - An oracle specific Handle object SYNOPSIS
DESCRIPTION
This module provides a subclass of Jifty::DBI::Handle that compensates for some of the idiosyncrasies of Oracle. METHODS
connect PARAMHASH: Driver, Database, Host, User, Password Takes a paramhash and connects to your DBI datasource. database_version Returns value of ORA_OCI constant, see "Constants" in DBD::Oracle. insert Takes a table name as the first argument and assumes that the rest of the arguments are an array of key-value pairs to be inserted. build_dsn PARAMHASH Takes a bunch of parameters: Required: Driver, Database or Host/SID, Optional: Port and RequireSSL Builds a dsn suitable for an Oracle DBI connection blob_params column_NAME column_type Returns a hash ref for the bind_param call to identify BLOB types used by the current database for a particular column type. The current Oracle implementation only supports ORA_CLOB types(112). apply_limits STATEMENTREF ROWS_PER_PAGE FIRST_ROW takes an SQL SELECT statement and massages it to return ROWS_PER_PAGE starting with FIRST_ROW; distinct_query STATEMENTREF takes an incomplete SQL SELECT statement and massages it to return a DISTINCT result set. AUTHOR
Jesse Vincent, jesse@fsck.com SEE ALSO
Jifty::DBI, Jifty::DBI::Handle, DBD::Oracle perl v5.14.2 2011-04-26 Jifty::DBI::Handle::Oracle(3pm)
All times are GMT -4. The time now is 04:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy