I'm writing a program that mimics a unix shell. It's supposed to take commands with arguments and execute them. I'm having trouble passing in the arguments into the execlp call to correctly execute the program. Here's the code I have:
Code:
// Construct the command argument array
char* args[argsEndIndex]; // Array to hold command arguments
int i = 0; // Loop counter to loop through command
int j = 0; // Loop counter for argument array
while (i <= argsEndIndex)
{
if (i != 0)
{
args[j] = cmdParts[i];
j++;
}
i++;
}
execlp("/bin/ls", "ls", args, NULL);
cmdParts is a char* array that contains the formatted command inputted. I parsed through the command above this code to insert characters so the pointers point to null terminated strings. That's also how I got argsEndIndex. For example I input this command:
Code:
ls -a -l
argsEndIndex gets correctly set to 2 because that's the index of the last argument in the command. 0 is obviously the command itself. Now when I make the execlp call I get:
Code:
ls: cannot access sH*?vH*?y: No such file or directory
Which I'm assuming it's accessing garbage data somewhere through the args array but I can't figure out why it's doing it because I'm correctly setting each element of the array.
I can post the whole code if you need it but it's long so I tried to keep this short. Any help is appreciated. Thanks!
$get problem
Hi Guys ... can you please tell me what i am doing wrong hereCode: <?php $ShowBookmark = "False"; include 'Include/Header.php'; if (Get_QString('Post') == "True") {
need to apply an if/else statement to Tim Thumb script
Not sure how to work this. I essentially want to call a variety of image sizes based on which stylesheet a user chooses from the administration backend of a wordpress theme. The sizes of the images
Extract text from string
Hi folks,I have a string that looks like this:aaaaaaaaaa: bbbbbbbbbb (ccccccccc) dddddddddddddddddddddeeeeeeeeeeeeeeeeeeeee(format can't be changed - lengths of strings will vary) and I need to
BAPI BBP_INB_DELIVERY_CREATE - material number missing in delivery
Hi Experts,
Array disappearing in foreach loop
Okay, I have this problem where an array will become undefined in a foreach loop.Here is the function plus a couple comments:Code: [Select]function mineResources($nation) {global $db;$resources =
button help
i originally had this but realised it is much easier to have a button.Code: <?php$search = $_GET['search'];$checkbox = $_GET['checkbox'];if($checkbox ==
Hotlinking Picasa as the image folder of a website
Hi there PHP freaks, I would like to create a private album in Picasa to use it as the image folder for my website, I want this album private so images can only be accessd from my website, so I guess
standard ALV application toolbar, into custom report....
HI,
While Problem
i am having a problem with a while statement here is the code Code:
Sending a hyperlink through mail
HI all,