Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 445
  • Last Modified:

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

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
TylerRick
Asked:
TylerRick
  • 4
  • 3
  • 2
  • +2
1 Solution
 
nedvisCommented:
try changin semicolon (  :   )   to   pipe character (  |  )

nedvis
 
0
 
DonConsolioCommented:
omit the ";" - the "&" should be enough to terminate the command

use this:
./script/server & ttail -f log/development.log &
0
 
nedvisCommented:
TylerRick , please,  just ignore my previous post

nedvis
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
pjedmondCommented:
./script/server & tail -f log/development.log &

making sure that you can spell tail ;)

(   (()
(`-' _\
 ''  ''
0
 
ahoffmannCommented:
> omit the ";"  ..
dooh, another reason to bash bash
:() { :; };:
0
 
pjedmondCommented:
:() { :; };:

Is this an obfuscated bash coding competition?

http://www.de.ioccc.org/main.html
0
 
ahoffmannCommented:
no, not obfuscated, sophisticated bashing :-))
try yourself in a script, but have the kill button handy ...

sorry for being off-topic
0
 
TylerRickAuthor Commented:
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
 
ahoffmannCommented:
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
 
pjedmondCommented:
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
 
ahoffmannCommented:
pjedmond, that's what I said with more words (which is unusal for me;-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now