Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I developed a Java application. I divided the application into 5 sub-applications, and created a service wrapper to each sub application using shell scripts:


Now I want to create a startup script startup.sh to execute all the wrapper scripts:

sh subaap1/bin/app.sh start
sh subaap2/bin/app.sh start

But when I run it, I get:

Unexpected command: start

How can I fix this?

share|improve this question
As far as I can tell, that error is coming from your application. What command do you type to just run subaap1? – Mikel Apr 5 '11 at 7:39

You shouldn't need to use sh in your script to run your sub applications.

Just use:

subaap1/bin/app.sh start
subaap2/bin/app.sh start

Updated as per comments below:

your version should work, however you need to know what shell sh is calling. It may be that you have the wrong shell, or the permissions on your apps are incorrect for the shell you are trying to use.

share|improve this answer
Are you sure? bash will pass the arguments through to the script you're running (that's what my sh is symlinked to); I don't know about other shells – Michael Mrozek Apr 5 '11 at 11:58
@Michael - will it pass them through if you use sh? You could be right - I just don't do it that way. I always surround mine in quotes if I want to do that. Or as here, just remove sh and bash is happy to assume the line is an application. – Rory Alsop Apr 5 '11 at 12:26
I have try to execute subaap1/bin/app.sh start from command line, and it works perfectly. Now I change the shell script without sh but I got startup.sh: line 2: subaap1/bin/app.sh: Permission denied. Any suggestion sir ? – adisembiring Apr 5 '11 at 12:35
Yes, I tried sh /path/to/shell/script arg and the arg made it through. It might depend which shell sh is actually linked to though – Michael Mrozek Apr 5 '11 at 12:35
@Michael - good point! sh could go somewhere other than bash. – Rory Alsop Apr 5 '11 at 12:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.