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

  • SEARCH
  • Home
  • 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 7877305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:20:03+00:00 2026-06-03T03:20:03+00:00

I found, that LaunchCtl skips arguments when using its ‘submit’ protocol. I have the

  • 0

I found, that LaunchCtl skips arguments when using its ‘submit’ protocol.

I have the following script (script.sh):

#!/bin/bash
arg1="$1"
arg2="$2"
arg3="$3"
arg4="$4"
echo $arg1$arg2$arg3$arg4
exit 1

When I call script.sh from terminal, there’s no problem with passing arguments into it.
When I do the same thing through LaunchCtl, something goes wrong and the first argument disappears.

launchctl submit -l MyUniqueScript -p ROOT/script.sh -o ROOT/out.txt -e ROOT/err.txt "abc" "def" "ghi" "jkl"

I even check my process

launchctl list MyUniqueScript

I have all my arguments right there. Terminal prints them out.

{
"Label" = "MyUniqueScript";
"LimitLoadToSessionType" = "Background";
"OnDemand" = false;
"LastExitStatus" = 256;
"TimeOut" = 30;
"Program" = "/Users/ROOT/script.sh";
"StandardOutPath" = "/Users/ROOT/out.txt";
"StandardErrorPath" = "/Users/ROOT/err.txt";
"ProgramArguments" = (
    "abc";
    "def";
    "ghi";
    "jkl";
);
};

But what I have in out.txt is quite messed up:

defghijkl

Rather than

abcdefghijkl

Can anyone help me out with this? Does anyone know what I should do, or what Im mistaken?

I must also tell, that the above small example is, of course, not the original script I’m working on. This is just easier to show my problem with.

Please help me! Thanks!

  • 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-06-03T03:20:05+00:00Added an answer on June 3, 2026 at 3:20 am

    Your launchctl syntax is wrong. The first “argument” should be the path to the script:

    launchctl submit -l MyUniqueScript -p ROOT/script.sh -o ROOT/out.txt -e ROOT/err.txt -- ROOT/script.sh "abc" "def" "ghi" "jkl"
    

    From the man page:

    submit -l label [-p executable] [-o path] [-e path] — command [args]

    The -p setting appears to be for aliasing, though I’m not sure why that would be useful

    –p program
    What program to really execute, regardless of what follows
    the — in the submit sub-command.

    So in your case, launchctl is treating your first argument as the script to be run, but really running your script because you specified it as the executable with -p. Specify the script as arg 0, as given above, or just drop the -p specification and include the path to the script immediately before its args.

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

Sidebar

Related Questions

I found that PHP5 isn't calling a __destruct() function if I have the following
I found that using declaring jQuery Autocomplete as the first function in your script
I found that using Smarty with PHP, sometimes extra time will need to be
I found that I have to perform a swap in python and I write
I found that each thread still has its own registers. Also has its own
I found that you can't read from some sites using Python's urllib2(or urllib). An
i found that when using android TabActivity to open tabs where each tab is
I found that many sites using sub-domain to handle login. one of them is
I found that MinGW Win32 compatibility layer has following definition in ndis.h: #define NdisGetCurrentSystemTime
I found that using BmpBitmapEncoder to render any type of image works, the only

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.