LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Bash shell script question... (https://www.linuxquestions.org/questions/linux-newbie-8/bash-shell-script-question-717174/)

linus72 04-06-2009 08:44 AM

Bash shell script question...
 
Let's say I have a script that opens Gedit when Gnome comes on in Ubuntu, how would I make the script so that 2 or more Gedits open when I boot into Gnome??
Basically it would just launch 2 or more Gedit's simultaneously-but could I also make it so that there is a slight pause before each one opens, so that it won't overload something-like a 1 second pause between instances appearing??
And no, I'm not really talking about Gedit, but any app...
Thanks

rizwanrafique 04-06-2009 09:04 AM

Code:

for num in 1 2 3; do
    gedit --new-window
    sleep 1s
done

And yes you can use any other than gedit there :-)

linus72 04-06-2009 09:12 AM

OK-but I gotta break down and tell you what I'm trying to do for my own clarity...

With Billix there is a script- "dsl-linux.sh", which brings up an instance of Qemu playing DSL out of the folder/USB/CD.

I have modified this script heavily and have it working correctly-'cause if you use Billix and try to use this script it won't work 'cause there are piece's missing from the Billix Qemu folder.
Anyway, I have fixed the script and added the missing components and everything works great now-see screen shot here-reply#92

( http://www.linuxquestions.org/questi...-works-714322/ )

Anyway-so I wanna be able to invoke the script and call up the Qemu's one at a time-but automatically and make it so that it can ad-infinitum by uncommenting,etc.

linus72 04-06-2009 09:15 AM

Sorry-I forgot to include the script!

Code:

qemu/qemu -L qemu/ -soundhw sb16
-kernel linux24 -initrd minirt24.gz
-hda KNOPPIX/KNOPPIX -hdb qemu/harddisk
-append "qemu frugal quiet modules=hdb
nousb noscsi nofirewire atapicd noideraid
noacpi acpi=off noapm noagp nomce"


linus72 04-06-2009 12:01 PM

Here's my script so far but I can't figure out how to make it pop up 1 or more Qemu's simultaneously once invoked.
As it is now it opens and runs 1 Qemu, then when ypu click on the X button to kill Qemu another pops up, etc.
That's not what I want..how do I make it pop up each instance of Qemu automatically at about an interval of 1-3 seconds???


Code:

#!/bin/sh
# $Id: invoke Qemu ad-infinitum, boots multiple instances of DSL playing
# on Qemu 04/06/09 root Exp root $
# -------------------------------------------------------------------------
# Purpose:
#  To have the ability to play an infinite number of DSL's on Qemu VM's
#  while inside the livecd/usb, within another Virtual system, and out
#  of the folder on your Desktop!
# Needed:
#  My MultiDistro-ToolKit-v4.20.iso CD, or DSL-embedded.zip, or Billix.
# Author:
#  Bryan Starr <thepenandpaper@gmail.com> 04/06/09
# -------------------------------------------------------------------------

Path=dsl-linux.sh

for num in 1 2 3; do
    qemu/qemu -L qemu/ -no-kqemu -soundhw sb16 -kernel linux24 -initrd minirt24.gz -hda DSL/KNOPPIX -append "qemu frugal  quiet modules=hdb nousb noscsi nofirewire atapicd noideraid noacpi acpi=off noapm noagp nomce vga=791 BOOT_IMAGE=knoppix knoppix_dir=DSL KNOPPIX_DIR=DSL"
    sleep 1s
done

I know it's something simple-but I'm a newb too.

repo 04-06-2009 12:07 PM

you could add the "&" to put the process in the background.

linus72 04-06-2009 12:13 PM

What do you mean "&", put it where?
Basically when I invoke the script I want 1+ instances of Qemu playing DSL. Each instance would "appear" at about a second apart or so.
So, it needs to have a variable to set how many pop up and how far apart in time they each pop up-right?
Like say I want it to open 3 Qemu's at 2 seconds apart-like that.

repo 04-06-2009 12:17 PM

Code:

for num in 1 2 3; do
    qemu &
    sleep 1s
done


linus72 04-06-2009 12:31 PM

Your A Bad MoFO Repo!

Ha!

Here's what I got now-calls each one up about a second apart too.

Code:

#!/bin/sh
# $Id: invoke Qemu ad-infinitum, boots multiple instances of DSL playing
# on Qemu 04/06/09 root Exp root $
# -------------------------------------------------------------------------
# Purpose:
#  To have the ability to play an infinite number of DSL's on Qemu VM's
#  while inside the livecd/usb, within another Virtual system, and out
#  of the folder on your Desktop!
# Needed:
#  My MultiDistro-ToolKit-v4.20.iso CD, or DSL-embedded.zip, or Billix.
# Author:
#  Bryan Starr <thepenandpaper@gmail.com> 04/06/09
# -------------------------------------------------------------------------


for num in 1 2 3; do
    qemu/qemu -L qemu/ -no-kqemu -soundhw sb16 -kernel linux24 -initrd minirt24.gz -hda DSL/KNOPPIX -append "qemu frugal  quiet modules=hdb nousb noscsi nofirewire atapicd noideraid noacpi acpi=off noapm noagp nomce vga=791 BOOT_IMAGE=knoppix knoppix_dir=DSL KNOPPIX_DIR=DSL" &
    sleep 1s
done

That's awesome, strangely it's not actually using the "dsl-linux.sh" at all-I had to input the dsl-linux.sh directly instead of "dsl-linux.sh &"
so I removed the "Path" command.
How do I get it to find the dsl-linux.sh, I tried "Path=dsl-linux.sh" and "Path=/dsl-linux.sh" neither worked but it's all in the same folder.
I don't need it but would like to know.
And thanks Repo-you get the official name of the script-"repolator.sh" or what?

repo 04-06-2009 12:40 PM

is dsl-linux.sh the script you want to execute?
I don't see it in the script...
perhaps
./dsl-linux.sh &

linus72 04-06-2009 01:05 PM

That's the entirety of dsl-linux.sh below no bin bash or anything.
That's the original from Billix-0.24

Code:

qemu/qemu -L qemu/ -soundhw sb16
-kernel linux24 -initrd minirt24.gz -hda
KNOPPIX/KNOPPIX -hdb qemu/harddisk -append
"qemu frugal quiet modules=hdb nousb noscsi
nofirewire atapicd noideraid noacpi acpi=off
noapm noagp nomce"

It is missing some things and sloppily written 'cause there is no "qemu/qemu", no "-hdb qemu/harddisk" and so no "modules=hdb" 'cause there is no "hdb".

If you've been reading my post about my multidistro stuff-I couldn't get dsl-linux.sh to work, so i started looking around in the Billix/qemu folder snd it's missing both "qemu" and "harddisk"!
I found an obscure UK mirror hosting Billix old and new, was able to peer inside each one and discovered Billix-0.18 was the last time the qemu folder had "qemu" and "harddisk"!
This kinda pissed me off 'cause whoever puts out Billix has put out 4 versions since 0.18 and none of them work!
I downloaded ver 0.18, added the "qemu" and "harddisk" to the 0.24 qemu folder and it still wouldn't go!
Damn it Jim!

I now have it down pat-maybe.
The original line above has been modified to my version at the above reply.
The "harddisk" thing is 48MB and must be DSL or something 'cause when I did get 0.24 working, an old version of DSL popped up-because it was using the "harddisk" from 0.18 which has an older version of DSL!

To make problems worse-the DSL folder in Billix-0.24 is named"KNOPPIX" and would not work till I made it "DSL"

So, after editing it this whole weekend and hunting down google I finally got it!

Wanna see a cool screen shot?
The screenshot on my "project post", reply#92
That's Billix DSL running live off my USB while 3 Qemu's play-note only 125MB RAM used too!
( http://www.linuxquestions.org/questi...322/page7.html )

Anyway Repo I got it all working now and about to release my greatest ever MultiDistro-ToolKit-v4.20 for CD/USB!
Now it can play DSL on Qemu ad-infinitum via "repolator.sh"!
The new multidistro is 492MB and has all this-
1 SystemRescueCD-1.1.7 (just came out today)
2 UltimateBootCD-4.1.1
3 DSL-4.4.10 (w/"repolator.sh" & "repolator.bat" for Linux/Windows)
4 NetbootCD-2.2 (net-installs Ubuntu/Debian/Fedora/Slackware/CentOS/OpenSUSE and Mandriva!
5 ZorOS-3.4 (Slackware based-awesome HW detection!
6 NTPassWord
7 Balder(FreeDOS)

That's a hellacious toolkit for a 512MB USB huh?
I'm getting ready to upload it now...

linus72 04-06-2009 02:35 PM

OK-now how do I make the .bat file do the same as the repolator.sh?
That is, create multiple instances of qemu when it's executed?

Code:

REM Start qemu on windows.

@ECHO OFF



START qemu\qemu.exe -L qemu/ -no-kqemu -m
128 -soundhw sb16 -localtime -kernel linux24
-initrd minirt24.gz -hda KNOPPIX/knoppix
-append "qemu sb=0x220,5,1,5 frugal quiet
noscsi nousb nofirewire atapicd noideraid
noacpi acpi=off noapm noagp ide1=noprobe
ide2=noprobe nomce BOOT_IMAGE=knoppix
knoppix_dir=DSL KNOPPIX_DIR=DSL"



CLS

EXIT

I really am not familiar with .bat files...


All times are GMT -5. The time now is 04:59 AM.