Find the answer to your Linux question:
Results 1 to 8 of 8
Hi, I was making a bash script to do open three programs in one click. I've gotten the variables all done but I can't get it to work. When I ...
  1. #1
    Just Joined!
    Join Date
    Apr 2008
    Posts
    30

    BASH variable help!

    Hi,

    I was making a bash script to do open three programs in one click. I've gotten the variables all done but I can't get it to work. When I run the bash script it won't open the second program until the first one is closed. How do I get it to open the 1st one, then the 2nd, and then the 3rd right after each other?

  2. #2
    Linux Guru smolloy's Avatar
    Join Date
    Apr 2005
    Location
    CA, but from N.Ireland
    Posts
    2,413
    It would be helpful to see the script, but perhaps you need to use the ampersand (&) character?
    Code:
    program1 &
    program2 &
    program3 &
    This will "background" each of the programs and should stop the shell waiting for them to return a value before proceeding to the next program.
    Registered Linux user #388328 || Registered LFS user #15880
    AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
    Need instant help? Try us on IRC -- #linuxforums on freenode

  3. #3
    Just Joined!
    Join Date
    Apr 2008
    Posts
    30
    Quote Originally Posted by smolloy View Post
    It would be helpful to see the script, but perhaps you need to use the ampersand (&) character?
    Code:
    program1 &
    program2 &
    program3 &
    This will "background" each of the programs and should stop the shell waiting for them to return a value before proceeding to the next program.
    Okey dokey here is the script I have (I think I did it wrong):

    #!/bin/bash
    JACK="jackd -d alsa is"
    QSYNTH="qsynth"
    ROSEGARDEN="rosegarden"
    $JACK
    $QSYNTH
    $ROSEGARDEN

  4. #4
    Linux Guru smolloy's Avatar
    Join Date
    Apr 2005
    Location
    CA, but from N.Ireland
    Posts
    2,413
    Try this,
    Code:
    #!/bin/bash
    JACK="jackd -d alsa is &"
    QSYNTH="qsynth &"
    ROSEGARDEN="rosegarden &"
    $JACK
    $QSYNTH
    $ROSEGARDEN
    The ampersands after each of the commands will background the processes as I mentioned in my previous post. Let us know if it works.
    Registered Linux user #388328 || Registered LFS user #15880
    AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
    Need instant help? Try us on IRC -- #linuxforums on freenode

  5. #5
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    smolloy solved the problem, but, might I ask why are you using variables there?

    I can't see a purpose behind it if all you are doing is declaring them just to launch the command three lines below.

  6. #6
    Just Joined!
    Join Date
    Apr 2008
    Posts
    30
    Ok thanks. It worked with the &. Now I just have one more question. How do I run the script from terminal? I just wanna be able to type something in the terminal command line and then it do what the script says. THANKS!!!

  7. #7
    Just Joined!
    Join Date
    Apr 2008
    Posts
    30

    Talking

    Ok, nevermind about my last post. I have to drag the icon into terminal and push enter. Duh. I forgot. Ok, so thanks for all of your help you guys!!!!! You've made my day!!!!!!!!!
    Bring on the dancing bananas!!!!

  8. #8
    Linux Guru smolloy's Avatar
    Join Date
    Apr 2005
    Location
    CA, but from N.Ireland
    Posts
    2,413
    I didn't know that dragging an icon into a terminal worked like that! Cool!

    You could also add the script to your path by moving it to /usr/local/bin, or by creating a soft link to your script in /usr/local/bin.

    Or change to the directory containing your script and enter its name preceeded by ./
    i.e.
    Code:
    ./yourscript.sh
    Registered Linux user #388328 || Registered LFS user #15880
    AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
    Need instant help? Try us on IRC -- #linuxforums on freenode

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...