Why oh WHY doesn't this work?execlp("FUCKYOU", (char *)huh[i], (char *)huh[++i])and just for shits, huh is some random ass array of integers.command line FUCKYOU 1 2, for example, works fine.nubwork[Edited on February 7, 2008 at 10:10 PM. Reason : ]
2/7/2008 10:09:33 PM
I FEEL YOUR *NIX PAIN
2/7/2008 10:13:39 PM
what's not working? compilation error?
2/7/2008 10:31:12 PM
Compiles fine. Just seems to skip over it altogether.I could just have FUCKYOU set to print out "fuck you," but nothing happens.Unless I'm just a compelte tard and nothing's supposed to happen[Edited on February 7, 2008 at 10:36 PM. Reason : ]
2/7/2008 10:36:42 PM
is FUCKYOU in the path or are you providing the entire path?[Edited on February 7, 2008 at 10:39 PM. Reason : also don't be lazy and see what it returns]
2/7/2008 10:38:44 PM
same path[Edited on February 7, 2008 at 10:39 PM. Reason : ]
2/7/2008 10:39:09 PM
don't know what i did, but finally got it to return a vlue....of course it indicates an error. checking errno just says unknown error i'm assuming whatever the hell FUCKYOU is taking for parameters doesn't like the way it's being casted. hurray.....now wtf do i do[Edited on February 7, 2008 at 10:50 PM. Reason : ]
2/7/2008 10:44:00 PM
does FUCKYOU take 2 char pointers?
2/8/2008 8:24:49 AM
well let's just say it doesn't - it's supposed to, mind you.i decided to write my own FUCKYOU just to see if I could get the execlp to workso now FUCKYOU is :
int main(int argc, char* argv[]){ cout << "argv[0]" << argv[0] << endl; cout << "argv[1]" << (int)argv[1] << endl; cout << "argv[2]" << (int)argv[2] << endl; return 0;}
char args[] = { numbers[numIndex], numbers[++numIndex] };execlp( "FUCKYOU", args );
2/8/2008 5:50:19 PM
The arguments represented by arg0... are pointers to null- terminated character strings. These strings constitute the argument list available to the new process image. The list is terminated by a null pointer. The arg0 argument should point to a filename that is associated with the process being started by one of the exec functions.
2/9/2008 8:33:42 AM
yeah, I didn't even notice this:
2/9/2008 12:56:52 PM
2/9/2008 3:23:33 PM
so i dont really know what you're trying to do at all, but if you're trying to get integers from the command line, if you're positive they're going to be ints, do an atoi(argv[1]) and it'll return a proper int.
2/9/2008 6:09:53 PM
and actually it looks like you're misinterpreting how to use execlp ... you need to properly setup your args - argv[0] should always be the name of the executable. this is assuming FUCKYOU is in your current path, as well.int retVal;retVal = execlp ("FUCKYOU", "FUCKYOU", argv[1], argv[2], (char *)0);i have a feeling that'll do exactly what you're trying to do.
2/9/2008 6:15:48 PM
That's one of the preconditions he violates, but to say resolving that would result in it working would still be assuming execlp never copies it as a null-terminated string before the next process gets the pointer. If it does, and say you're passing (int) 0xff0000ff, you're gonna get ff00 from the copy and then derefencing will append whatever crud happens to follow it in its new location. I imagine that would be implementation-specific behavior.[Edited on February 9, 2008 at 6:31 PM. Reason : .]
2/9/2008 6:29:33 PM
^^ & ^ both dead on.Thanks for the help guys.I'm still getting fucked by ^ that, though.If I pass argv[1] and argv[2] directly into excelp it works fine (whether it's supposed to or not is another story). God forbid I try to pass anything else, though
2/10/2008 4:15:09 PM
nm, i figured out my stupid mistake thanks again everyone!no way in hell I could have done it without help
2/10/2008 5:01:51 PM
you can't get off that easy. what was the mistake
2/10/2008 5:07:49 PM
he wasn't calling it correctlylooks like it's supposed to be:int rc = execlp("executable name", "executable name", some null terminated char *s, NULL);and he was casting ints to pass in instead of passing character strings.
2/10/2008 8:40:29 PM
^ basically got it.Big retard moment on my part I just used sprintf to drop the ints into a null terminated char array and it worked perfectly[Edited on February 19, 2008 at 10:33 AM. Reason : ]
2/19/2008 10:26:41 AM