Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The question is somewhat related to the question asked here, http://stackoverflow.com/questions/5130847/shell-multiple-commands-in-one-line, but the difference is, I need to execute the whole commands whether or not the commands are successful or not. So I presume, && is not an option right? Can I use ; separated commands and eval or bash; something like

eval cd /home/user/homedir ; /home/user/homedir/sbin/daemon.sh --config /home/user/homedir/etc/dd2 --script /home/user/homedir/sbin/dd3 start action1

or something like that?

Please advise,

share|improve this question
    
Is /home/user/homedir/sbin/daemon.sh --config /home/user/homedir/etc/dd2 --script /home/user/homedir/sbin/dd3 start action1 all one command? What can you tell us about what /home/user/homedir/sbin/daemon.sh does? (Also, why do you want to cd to /home/user/homedir and then use full pathnames?) –  Scott Dec 21 '12 at 17:54
add comment

2 Answers

up vote 0 down vote accepted

';' works. You could also use '&', simplified like this:

/home/user/homedir/sbin/daemon.sh --config & /home/user/homedir/etc/dd2 --script & /home/user/homedir/sbin/dd3 start action1

(Simultaneous execution, see comment for clarification below)

share|improve this answer
1  
That would run the two commands simultaneously in separate processes. (1) This doesn't sound like what was asked for. (2) This almost never makes sense when the first command is a cd, because it means that the second command won't get the benefit of the cd; i.e., it will run in whatever directory the user (the shell) is in when the command is typed, and not in /home/user/homedir, as seems to be intended. –  Scott Dec 21 '12 at 4:55
    
For simultaneous execution, then: cd /home/user/homedir; /home/user/homedir/sbin/daemon.sh --config & cd /home/user/homedir; /home/user/homedir/etc/dd2 --script & cd /home/user/homedir; /home/user/homedir/sbin/dd3 start action1 –  Sectio Aurea Dec 21 '12 at 4:59
    
yup, Scott is correct. As Sectio Aurea pointed out we should use the multiple cd to execute the scripts simultaneously. –  Aczire Dec 21 '12 at 5:06
    
Somebody is confused. The question gives the appearance that ~/sbin/daemon.sh ––config ~/etc/dd2 ––script ~/sbin/dd3 start action1 is one command. I asked the OP for confirmation and got no indication to the contrary. But the above answer has taken this command and broken it into three parts. This is not an answer to this question, as stated. Neither grep; Scott; /etc/passwd nor grep& Scott& /etc/passwd& will display my user ID information. –  Scott Jan 5 '13 at 0:36
    
You're right technically. It's possible that it's one command but didn't seem at all likely - looking more like a naive use of bash. I answered based on that hunch about the 'real question' and expected the OP to correct me if that wasn't useful. –  Sectio Aurea Jan 9 '13 at 0:05
add comment

What you have is fine, except I would leave off the eval unless you have some reason for having it (I don't see any reason).

share|improve this answer
add comment

Your Answer

 
discard

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.