Sponsored Content
Top Forums Programming execl() + redirecting output to text files Post 302166841 by JamesGoh on Wednesday 13th of February 2008 01:10:07 AM
Old 02-13-2008
execl() + redirecting output to text files

Im currently using execl() to run the ls command and redirect the output to a text file. Unfortunately, when I check the text file, no information has been written to it.

I am calling execl() with the ls command like this

Code:
execl( "/bin/ls" , "-al" , '>' , "dirlist.txt" ,(char *) 0 );

What are some possible causes of my above problem ? cheers
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Redirecting output to multiple log files?

If I wanted to redirect output to multiple log files, what would be the best way to do that? echo "Unix is awesome" >>unixgod.log >>unixgod.log (3 Replies)
Discussion started by: darthur
3 Replies

2. Shell Programming and Scripting

Redirecting OUTPUT

Hi, I want to move the output of a command/script to a file as well as to to be displayed on stdout. Can anybody help me in this. Thanks in advace .. -Chanakya M (1 Reply)
Discussion started by: Chanakya.m
1 Replies

3. Shell Programming and Scripting

Redirecting echo output to 2 flat files

Hello all, I have the following 2 questions.. 1) I would like to capture the output of an echo command to 2 different files at the same time. This does not seem to work. Any ideas? echo ==== started on `date` ==== >> res1.log res2.log 2) Would it be possible to just get the 5th... (2 Replies)
Discussion started by: luft
2 Replies

4. Shell Programming and Scripting

Redirecting to different output files with awk.

Well, it didn't take me long to get stumped again. I assure you that I'm not mentally deficient, just new to scripting. So, here's the gist. I want to redirect output from awk based off of which branch of an if-else statement under which it falls. #!/bin/bash #some variables... (2 Replies)
Discussion started by: mikesimone
2 Replies

5. Red Hat

write execl output to file

hi, how to write the resullt of execl() into another file. i used write(fd,execl()); (1 Reply)
Discussion started by: Mahendravarma
1 Replies

6. UNIX for Dummies Questions & Answers

redirecting script output

Hello, I am interested in taking the output from a script i wrote and using it as input to a different script i wrote. So for example i want to take the output from program2 and use it as a parameter for program1. I didnt think i could use the >> symbols because i think that is just for .txt... (4 Replies)
Discussion started by: GmGeubt
4 Replies

7. Shell Programming and Scripting

Redirecting the output

For example, if we run the below command, symcfg list -thin -pool , results in an output most of the times and if the out is generated i'm able to redirect the output to a file. but sometimes it doesnt result any output and even though the output is being redirected, i can see "No Thin Pools "... (2 Replies)
Discussion started by: web2moha
2 Replies

8. Post Here to Contact Site Administrators and Moderators

Redirecting grep output to multiple files

Hi All, I am trying to redirect the grep output to multiple files, can you please help with that. Below is the command im using to match my pattern grep \<proxyType\>$PxyType $DIR/EndureFiles.json > File_Name*.json Note : $DIR and $PxyType is already defined in my script Im able... (0 Replies)
Discussion started by: Deena1984
0 Replies

9. Shell Programming and Scripting

Awk: Print Error While Redirecting output in multiple Files

Hi, I have a following code in which I am unable to redirect to multiple files. Can anybody please help with some corrections awk -F, '{ if ( substr($1,26,2)=="02" && substr($1,184,14)=="MTSCC_VALFIRST") { array1++ array2++ array3++ } else if (substr($1,26,2)=="03" &&... (4 Replies)
Discussion started by: siramitsharma
4 Replies

10. Shell Programming and Scripting

Redirecting the results to different output files

Hi All, I am trying a shell script and need your help on taking the results to different output files. I have tried the below code: nawk ' {CNF = (length()-10)/7 printf "%9s", substr ($0, 1, 9) for (i=0; i<=CNF; i++) T = substr ($0, 10+i*7, 7) TMP = 100 - (T + T + T + T + T + T + T + T... (24 Replies)
Discussion started by: am24
24 Replies
stdarg(3)						     Library Functions Manual							 stdarg(3)

NAME
stdarg - Handles a variable-length parameter list LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <stdarg.h> va_list void va_start ( va_list argp, parmN ); type va_arg ( va_list argp, type ); void va_end ( va_list argp ); PARAMETERS
argp Specifies a variable that the stdarg macros use to keep track of the current location in the parameter list. Do not modify this variable. parmN Specifies the last named parameter (the one just before the "..." in the execl() definition in the Example section). There must be at least one named parameter. type Specifies the type to which the expected argument will be converted when passed as an argument. Unsigned char or short arguments are converted to unsigned int, and float arguments are converted to double. Different types can be mixed, but it is up to the rou- tine to know what type of argument is expected because the type cannot be determined at run time. DESCRIPTION
The stdarg set of macros allows you to write portable functions that accept a variable number of parameters. Subroutines that have vari- able-length parameter lists (such as the printf() function), but that do not use the stdarg macros, are inherently nonportable because dif- ferent systems use different parameter-passing conventions. The stdarg macros are as follows: va_list Defines the type of the variable used to traverse the list. va_start() Initializes argp to point to the first unnamed argument. The va_start() macro will be invoked before any access to the unnamed arguments. va_arg() Returns the next parameter in the list pointed to by argp. va_end() Cleans up at the end. Your function can traverse, or scan, the parameter list more than once. Start each traversal with a call to va_start() and end it with va_end(). EXAMPLE
The following example is a possible implementation of the execl() function: #include <stdarg.h> #define MAXargS 100 /* ** execl is called by ** execl(file, arg1, arg2, . . . , (char *) 0); */ execl(char * file, . . .) { va_list ap; char *file; char *args[MAXargS]; int argno = 0; va_start(ap, file); while ((args[argno++] = va_arg(ap, char *)) != (char *) 0) ; /* Empty loop body */ va_end(ap); return (execv(file, args)); } NOTES
The calling routine is responsible for specifying the number of parameters because it is not always possible to determine this from the stack frame. For example, the execl() function is passed a null pointer to signal the end of the list. The printf() function determines the number of parameters from its fmt parameter. AES Support Level: Temporary use RELATED INFORMATION
Functions: exec(2), printf(3), varargs(3), vprintf(3) delim off stdarg(3)
All times are GMT -4. The time now is 06:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy