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
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
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
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
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
LEARN ABOUT DEBIAN
make-jpkg
MAKE-JPKG(1) General Commands Manual MAKE-JPKG(1)
NAME
make-jpkg - builds Debian packages from Java binary distributions
SYNOPSIS
make-jpkg [OPTION]... [FILE]
DESCRIPTION
make-jpkg builds a Debian package from the given Java distribution FILE.
Supported java binary distributions currently include:
* Oracle (http://www.oracle.com/technetwork/java/javase/downloads) :
- The J2SE Development Kit (JDK), version 6 (update >= 10), 7
- The J2SE Runtime Environment (JRE), version 6 (update >= 10), 7
- The J2SE API Javadoc, version 6 (update >= 10), 7
(Choose tar.gz archives or self-extracting archives, do _not_ choose the RPM!)
The following options are recognized:
--full-name NAME
full name used in the maintainer field of the package
--email EMAIL
email address used in the maintainer field of the package
--changes
create a .changes file
--revision
add debian revision
--help display help text and exit
--version
output version information and exit
Download a supported Java RE or SDK or API tar.gz or self-extracting archive from http://www.oracle.com/technetwork/java/javase/downloads
and execute make-jpkg file with the downloaded file. The program asks the user for additional information and builds a Debian binary pack-
age in the current directory.
The program requires about 200 MB free disk space in a temporary directory. The temporary directory defaults to /tmp but you can specify an
alternate directory by setting the environment variable TMPDIR.
EXAMPLE
To install Oracle(TM) 7 Standard Edition JDK, download a release - 64 bits version of update 2 from http://www.oracle.com/technet-
work/java/javase/downloads/jdk-7u2-download-1377129.html in this example - and invoke make-jpkg:
make-jpkg <path_to_download_directory>/jdk-7u2-linux-x64.tar.gz
This generate a Debian package in the current directory, that can be installed using dpkg:
dpkg -i oracle-j2sdk1.7_1.7.0+update2_amd64.deb
When you're done, you can delete initial download as well as generated package:
rm <path_to_download_directory>/jdk-7u2-linux-x64.tar.gz oracle-j2sdk1.7_1.7.0+update2_amd64.deb
ENVIRONMENT
TMPDIR base directory used for temporary files (defaults to /tmp)
J2SE_PACKAGE_FULL_NAME
full name used in the maintainer field of the package; if none is supplied then the default of "Debian Java Maintainers" is used.
J2SE_PACKAGE_EMAIL
email address used in the maintainer field of the package; if none is supplied the default of "pkg-java-maintain-
ers@lists.alioth.debian.org" is used.
SEE ALSO
update-java-alternatives(1)
AUTHOR
This manual page was written by Hubert Schmid <j2se-package@z42.de>.
It is now maintained by the Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>.
January 22, 2012 MAKE-JPKG(1)