Solved

How can I start and immediately background 2 scripts (script1 & ; script2 &)?

Posted on 2006-06-29
11
436 Views
Last Modified: 2008-02-07
I want to do this:

./script/server & ; tail -f log/development.log &

But I get this:

-bash: syntax error near unexpected token `;'

Is there a solution and what is it?



I tried this:

(./script/server &); tail -f log/development.log

which doesn't give a syntax error, but it's not a solution, because the resulting processes don't show up in `jobs`.
0
Comment
Question by:TylerRick
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 20

Expert Comment

by:nedvis
ID: 17012217
try changin semicolon (  :   )   to   pipe character (  |  )

nedvis
 
0
 
LVL 15

Accepted Solution

by:
DonConsolio earned 125 total points
ID: 17012306
omit the ";" - the "&" should be enough to terminate the command

use this:
./script/server & ttail -f log/development.log &
0
 
LVL 20

Expert Comment

by:nedvis
ID: 17012325
TylerRick , please,  just ignore my previous post

nedvis
0
 
LVL 22

Expert Comment

by:pjedmond
ID: 17012408
./script/server & tail -f log/development.log &

making sure that you can spell tail ;)

(   (()
(`-' _\
 ''  ''
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 17012972
> omit the ";"  ..
dooh, another reason to bash bash
:() { :; };:
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 22

Expert Comment

by:pjedmond
ID: 17013034
:() { :; };:

Is this an obfuscated bash coding competition?

http://www.de.ioccc.org/main.html
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 17013192
no, not obfuscated, sophisticated bashing :-))
try yourself in a script, but have the kill button handy ...

sorry for being off-topic
0
 

Author Comment

by:TylerRick
ID: 17013906
Thanks for your help, everyone!

Yeah, I don't know why bash has to be so weird. I just assumed that you could separate commands with ; ...

ahoffmann, what shell do you use, if I might ask?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 17015875
plain old (Bourne) sh for programming 'cause it's up/downward compatible ;-)
KISS - keep it simple stupid

csh, tcsh interactive; zsh sometimes; tclsh if I want lists; bash if all the others are missing (not too bad:)

Some other pros and cons:
  - bash and tcsh can be compiled with special default settings. It's most likely not done, but if, then you may spend a long time to debug some strange behaviours (in particular about reading/executing their resource files at various startups)
  - unfortunatelly some vendors hide the original csh and deliver their own buggy one as csh (HP could be named to blame here)-:
  - ksh is a nightmare, both in programming and using interactive 'cause you often have to check the version to know how to use some features/bugs; then there is pdksh (installed as ksh) which has not all functionality of original ksh
  - bash is strange when it comes to redirect streams
  - with csh it is strange, or even impossible, to handle sevaral streams
  + csh is intuitive to redirect STDOUT together with STDERR in any situation
  + bash and csh have an intuitive and easy to use "jobs" functionality
  + sh is the same on all systems (just some ancient Linux are strange)
  + ksh interactive is for people adicted to emacs ;-)
and finally bash is for bashers (fill in whatever reason, pro or con, you like:-)

STFW and you'll find some sites about pros&cons for each. Mainly csh is blaimed for programming 'cause some behaviours are not realy logical.
These are personal preferences, of course.
0
 
LVL 22

Expert Comment

by:pjedmond
ID: 17016336
IMHO - Stick with sh (bash), unless you have a good reason to use one of the others. Of course it's a matter of preference, but as I work on loads of different systems, commonality between distributions is the most important attribute to me:)

(   (()
(`-' _\
 ''  ''

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 17016366
pjedmond, that's what I said with more words (which is unusal for me;-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now