Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6113111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:49:18+00:00 2026-05-23T14:49:18+00:00

I am having trouble with NSProcessInfo’s arguments property. I am creating a command line

  • 0

I am having trouble with NSProcessInfo's arguments property. I am creating a command line tool that needs to decode base64 code that it has been passed from the internet using a PHP script, along with some other arguments. The data is passed fine, but for some reason. [[NSProcessInfo processInfo] arguments] returns 21 arguments, even though I pass just one base64 string.

Here’s the objective-c side of it:

NSArray *arguments = [[NSProcessInfo processInfo] arguments];

if ([[arguments objectAtIndex:1] isEqualToString:@"-s"])
{
    if ([arguments objectAtIndex:2] == nil)
    {
        printf("Error: No data\n");
        [pool drain];
        return 0;
    }

    NSString*data = [arguments objectAtIndex:2];

    if ([data length] == 0)
    {
        printf("Error: No data\n");
        [pool drain];
        return 0;
    }

    NSString*password = @"";

    if ([[arguments objectAtIndex:3] isEqualToString:@"-p"])
    {
        if ([arguments objectAtIndex:4] == nil)
        {
            printf("Error: No password\n");
            [pool drain];
            return 0;
        }
        else
        {
            password = [NSString stringWithString:[arguments lastObject]];
        }
    }

NSLog(@"Args: %i\n\n",[arguments count]); //returns 21? I expect 3.

The base64 code is a bit long, so I’ve put it here. Does anyone know why this code returns this many arguments? It’s supposed to be just one string?
Edit: I am stripping whitespaces in my PHP script. See here:

<?php

$url = $_GET['data'];

$query = "/Library/WebServer/email/emailsender -s";
$password = "-p somePassword";

$commandStr = trim("$query $url $password");

$commandStr = removeNewLines($commandStr);

echo $commandStr;

$output = shell_exec($commandStr);

echo "<pre>Output: $output</pre>";

function removeNewLines($string) {

    $string = str_replace( "\t", ' ', $string );
    $string = str_replace( "\n", ' ', $string );
    $string = str_replace( "\r", ' ', $string );
    $string = str_replace( "\0", ' ', $string );
    $string = str_replace( "\x0B", ' ', $string );

    return $string;

}

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:49:18+00:00Added an answer on May 23, 2026 at 2:49 pm

    When you send arguments to a program through the command-line, each argument is separated by a whitespace character. This means that if you post a string that contains spaces, your program will interpret it as many arguments. To prevent this behavior, you need to quote your strings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having trouble linking the Stomp.framework into an iPhone SDK application. http://code.google.com/p/stompframework/ I follow the
Having trouble with proper regex for RewriteCond RewriteCond %{REQUEST_URI} !^/foo/ Works as expected, that
Having trouble with the following segment of code. I'm getting a parameter count mismatch.
Having trouble creating my swap chain. I receive the following error. DX3dApp.obj : error
Having trouble where I think I need to provide most of my code to
Having trouble getting the javascript alert to display from my code behind. c# -
Having trouble with the db.alter command when changing a date field from null=True and
Having trouble getting one portion of my code to work. Building a rudimentary linked
Im having trouble with my Post and Comment to Post section of code. I
Having trouble converting the following code from dealing with IDs to Classes. Basicly what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.