Sponsored Content
Full Discussion: little program error.
Top Forums Programming little program error. Post 302259633 by joey on Tuesday 18th of November 2008 02:24:08 PM
Old 11-18-2008
little program error.

I am trying to work this little program, its not working..

Code:
int main()

{
               FILE *fp;
               char *args[40];
               pid_t child, exited_pid;
               int status = 0;
               *args[0] = "less";
               fp = popen("ls", "r");
               child = fork();
               if(child == 0)
              {
                      dup2(fp->fd, 0);
                      if(execvp(args[0], args) == -1)
                             {
                                printf("error");
                               exit(EXIT_FAILURE);
                              }

                wait(&status);
                wait(&status);
}


I got error.
Warning: assignment makes integer from pointer without a cast
Error: 'FILE' has no member named 'fd'
Error: expected declaration or statement at end of input.


My whole goal of the program is to execute ls, and read from that program & store it in the buffer. Then my second program (argss[0]) reads the input coming from there and uses it...


help plzSmilie
 

10 More Discussions You Might Find Interesting

1. Programming

Error Compiling C program

Hi All, I tried to compile a C program but i am getting error while Linking . it says Undefined reference to ' ' (here it gives a method name which is defined Globally ). Can any body tell the resaon and remedy for the same . Iam stuck up here . Thanks (3 Replies)
Discussion started by: Vivek
3 Replies

2. AIX

Program Error

Hi, my IBM 9117-570 model (mounting SF230_126 firmware version) gives an errpt like the following. The problem is that no SRC code found at IBM information center web site. Some ideas where are those SRC searchable ? O.S. is AIX 5.2- tkx E18E984F 1119200506 P S SRC ... (0 Replies)
Discussion started by: Carmen123
0 Replies

3. Shell Programming and Scripting

Error in AWK Program

Hi Friends, I need your help. I am not able to execute one awk program .If you can solve the following small program then i can solve other one. $ vi prg #!/bin/awk -f BEGIN { # Print the squares from 1 to 10 the first way i=1; while (i <= 10) { ... (3 Replies)
Discussion started by: bikas_jena
3 Replies

4. Shell Programming and Scripting

Need help with program error

#!/bin/csh # # Time of day greeting # # usage: greet # if ($#argv == 0) then set hour = ‘date +%H’ else set hour = $argv endif # if ($hour < 12) then echo "Good Morning\!" else if ($hour < 18) then echo "Good Afternoon\!" ... (2 Replies)
Discussion started by: glock1800
2 Replies

5. Linux

an error in perl program

Hi I am having a file with 243 lines.. The file format s given below eg P25787 hsa03050 1 P20618 hsa03050 1 P25786 hsa03050 1 P49721 hsa03050 1 P54132 hsa03440 1 Q13472 hsa03470 1 Q05513 hsa04530 hsa04910 hsa04930 3 Q04759 ... (0 Replies)
Discussion started by: binnybio
0 Replies

6. Programming

Runtime error in C++ Program - Help

All, I am getting this when i try to ran a program in HP unix. Things i came across 1. i have a system HP-UNIX where this same exe is working. 2. We have set a new HP_UNIX with the same configration and copied the exe to the new system we are getting this error. 3. Only... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

7. Programming

An error in my c++ program... please help urgent.

The following is a program to convert an infix expression to postfix expression. //Convert an infix expression to postfix expression... #include<iostream> #include<string> #include<cstdlib> using namespace std; char ifx,pfx,stk; int top=-1,n; void push(char ch) { if(top!=n) ... (6 Replies)
Discussion started by: poonam.gaigole
6 Replies

8. Solaris

Shell program error!!!

Hello guys, This is an executable shell program that I want to execute, but it doesn't execute and gives error. The shell program that I want to execute is taken from a well-reputed book on Solaris 10. Here is the program #!/usr/bin/bash if test -a $1 then echo "Number of lines in file " $1... (2 Replies)
Discussion started by: gabam
2 Replies

9. Programming

Error in executing the C program

Hello Friends, I have written a code for the unisex bathroom which makes a policy that when a woman is in the bathroom only other women may enter, but not men, and vice versa. This program consists of four functions which a user defines but these functions are not properly working while... (4 Replies)
Discussion started by: Ravi Tej
4 Replies

10. Programming

Error in my FORTRAN program

I have a Fortran program and I am writing out to logical unit 7. The program is reading from a text file and writing to the new file formatted. It gets through the read and writes some to the file but then stops with the following error: 1525-013 The sequential WRITE statement cannot be... (5 Replies)
Discussion started by: KathyB148
5 Replies
stcall(3)						    ShapeTools Toolkit Library							 stcall(3)

NAME
stCallEditor, stCallCmd, stCallCmdErrno, stFindProgram - call command processor with command string SYNOPSIS
#include <config.h> #include <sttk.h.h> int stCallEditor (char *editor, char *file, char *contents, char **newcontents); int stCallCmd (char *commandProcessor, char *commandString); int stCallCmdErrno; char*stFindProgram (char *fileName) DESCRIPTION
stCallEditor calls editor editor with file file and returns its contents after the editor session in newcontents. Return value is the length of the new text. On failure, 0 is returned to indicate the error. Newcontents is not updated and points to nowhere. On error the file will be removed. If contents points to a valid text, this text is put (not appended) into the temporary file before editor starts. Contents must be NULL terminated, otherwise strange things will happen. stCallCmd invokes commandProcessor as a child process and writes commandString to its standard input. The current process waits for termi- nation of the child process. stCallCmd returns the exit status of the child process reported by wait(2). The commandProcessor string may contain command line arguments to the command processor, separated by whitespace. (This is necessary for some programs to make them read commands from standard input.) The command processor program is searched for in the directories given in the environment variable PATH. If commandString does not end with a newline, a newline is added. stFindProgram returns the full pathname of programName if program is found and executable. Otherwise NULL. ENVIRONMENT
PATH List of colon-separated directoriy names where execvp(3) searches for the program to execute (default /bin:/usr/bin:/usr/ucb). SEE ALSO
wait(2) DIAGNOSTICS
On a successful call stCallCmd returns the exit status of the child process. If an error occured, stCallCmd returns a negative number as defined in sttk.h: CMDPROC_EMPTY An empty or NULL string has been supplied for commandProcessor. NO_MORE_CORE A call to malloc(3) or calloc(3) returned a NULL pointer. FORK_FAILED fork(2) could not create a child process. PIPE_FAILED A call to pipe(2) failed. WAIT_ERROR A call to wait(2) failed. EXEC_FAILED execvp(3) could not execute commandProcessor. CHILD_KILLED The child process was killed by an uncaught signal. WRITE_FAILED write(2) could not write commandString to the pipe. This usually happens when commandProcessor does not read its standard input and terminates before commandString is written. NO_PROGRAM commandProcessor could not be found. For the most error conditions the integer variable stCallCmdErrno (declared in sttk.h) contains additional information about the error con- dition, usually the contents of errno(3) after a failed system call. In the case of CHILD_KILLED, stCallCmdErrno contains the statBus of the child process as reported by wait(2). BUGS
On systems where no usable vfork(2) is available, the value of stCallCmdErrno does not make sense in case of EXEC_FAILED. Under IRIX stCallCmd sometimes (or always?) returns WAIT_ERROR where it should be EXEC_FAILED, NO_PROGRAM, or WRITE_FAILED. AUTHORS
Jurgen Nickelsen <nickel@cs.tu-berlin.de> and Andreas.Lampen@cs.tu-berlin.de sttk-1.7 Thu Jun 24 17:43:29 1993 stcall(3)
All times are GMT -4. The time now is 05:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy