goto's are evil. please learn loops.
Type: Posts; User: LightsOut06
goto's are evil. please learn loops.
what is m[i]? and what is n? You're getting a seg fault probably because you for loop is trying to put a value in some space that is not allocated.
i know this code is long, if anybody wants me to explain my thought process or something over aim or yim, pm me or something. I'm pretty desperate over here.
here's the output:
Pipe0
got completed
freeze before closes?
freeze before closes?
executing command ls
freeze before dupes and closes?
updated code still not working. I dont know what is wrong. I just cant get it working at all. Please any help or suggestions would be greatly appreciated. I've googled and googled, recoded and...
sorry to bump a really old thread, but how would you implement this using dup2s and closes?
changed the code to use 2d arrays
// Program asks user for input and tries to execute linux commands based on that input
// User can use multiple input piped commands ie ls | grep main | grep...
For some reason pipe() is returning an error when I try to pipe. Any idea why? Here's the code:
// Program asks user for input and tries to execute linux commands based on that input
// User...
same way at my school. I honestly know waaaay more people with gpas under 3.0 than over 3.0 (i go to an engineering school btw Univ Missouri-Rolla).
im in the midwest. St. Louis, Missouri.
I haven't obtained my degree yet, but this is the situation im looking at and it's really bothering me. I would hate to have wasted 5 years of my life working so hard to obtain this comp sci degree...
This problem works with 2 piped commands (ie ls | grep main) but when I try to do more than 2 commands the program freezes.The int main() basically does the i/o and the execute command function is...
This problem works with 2 piped commands (ie ls | grep main) but when I try to do more than 2 commands the program freezes.The int main() basically does the i/o and the execute command function is...
thanks a bunch. everything works now!
vector<string> left_args;
//left_comm_toks is a vector that stores strings.
// GetNumTokens returns the size of the left_com_toks vector
for(int i = 0; i < left_comm_toks.GetNumTokens(); i++)...
i know what execvp accepts. My problem is that I have a C++ style string not const char *, or char *const argv[]. I wouldnt to know how to convert the string into something execvp can accept. There...
i tried that that's still not what execvp wants for the second arg.
I'm trying to use execvp which has the prototype:
int execvp( const char *file, char *const argv[]);
I'm using a C++ style string to get input from the user. How can I convert this C++ style...
I'm trying to use execvp which has the prototype:
int execvp( const char *file, char *const argv[]);
I'm using a C++ style string to get input from the user. How can I convert this C++ style...
here is the addnode function btw:
void addNode(char *input)
{
struct node *nptr;
cptr = tptr;
if ((nptr = malloc(sizeof(struct node))) != NULL)
void RunShellLoop(struct prompt *pr)
{
Bool stillGoing = TRUE;
Bool execvp_worked = FALSE;
ssize_t readReturn = 0;
char *input = NULL;
char *lastCommand = NULL;
char...
the problem was that i never forked a new process. I dont know how i left that out lol.
here's some more code that exemplifies what i'm trying to do. Still having the same problem.
#define _GNU_SOURCE 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include...
Bool execute_command(char *input)
{
pid_t child_pid;
/* fork() == 0 for child process */
if(child_pid == 0)
{
char *argv[]={input, 0};
execvp(argv[0], argv);
^i think getline automatically does that.
However I think I fixed it. Thanks to Salem. I looked at his last post in my last thread and he said to make input = NULL before you loop again. That's...