LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 12-13-2005, 02:48 AM   #1
spx2
Member
 
Registered: Dec 2005
Distribution: debian
Posts: 160

Rep: Reputation: 30
small script


im trying to make this small script to start up a
bunch of programs but i dont know how to make them
start simoultaneously not one by one waiting for
each other to be closed.




then i want to include that script to be exectuted
asking for permission somewhere but that would be simple...

for the first part i really cant get it done
 
Old 12-13-2005, 02:54 AM   #2
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,178

Rep: Reputation: 49
[command] &

The ampersand (&) tells the program to execute in the background, allowing foreground processes to continue while it runs.

So you could easily put as many commands as you need and have them start as close to sychronously as possible.
 
Old 12-13-2005, 03:01 AM   #3
spx2
Member
 
Registered: Dec 2005
Distribution: debian
Posts: 160

Original Poster
Rep: Reputation: 30
thanks

thanks man you've really been of help

is there any equivalent to autoexec.bat to linux ?
if there is how do i configure it to run my script
but that will be after kde starts because all programs
included in my script are using kde.
thanks again
 
Old 12-13-2005, 03:13 AM   #4
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,178

Rep: Reputation: 49
Every distro has a file that executes upon boot, ~/.bashrc or ~/.bash_profile execute when someone opens a terminal, and every WindowManager (KDE, Gnome, Fluxbox, et cetera) all have their own. They also have startup directories (or similar) that should be well-documented on both this and their own sites.
 
Old 12-13-2005, 03:25 AM   #5
spx2
Member
 
Registered: Dec 2005
Distribution: debian
Posts: 160

Original Poster
Rep: Reputation: 30
just partially solve the problem(partially because not yet tested)
i read from here kde docs and i would like to quoute them

that i have to put the scripts in my $KDEHOME/env/
and thats all i think

Quote:
10.10. How do I run a program at KDE startup?


There are many ways to do that. If what you want to do is to run some scripts that would set some environment variables (for example, to start gpg-agent, ssh-agent and others), you can put these scripts into $KDEHOME/env/ and make sure their names end in .sh. $KDEHOME is usually a folder named .kde (note the period at the beginning) in your home folder. If you want scripts to be executed for all KDE users, you can put them under $KDEDIR/env/, where $KDEDIR is the prefix KDE was installed to (you can find this out using the command kde-config --prefix).
 
Old 12-13-2005, 03:29 AM   #6
spx2
Member
 
Registered: Dec 2005
Distribution: debian
Posts: 160

Original Poster
Rep: Reputation: 30
how can i ask for user input in the script ?
like " Do you want the programs to start ? Y/N"
and do some ifs according to this
also how do i jumpexit from a bash script ?
 
Old 12-13-2005, 04:46 AM   #7
spx2
Member
 
Registered: Dec 2005
Distribution: debian
Posts: 160

Original Poster
Rep: Reputation: 30
script finsihed

i managed to pull this non-orthodox code out...
im not too familiar yet with bash shell scripting.
i used mcedit to code it.
it seems tought that if at line 1
i put "exitloop = 0" instead of
"exitloop=0" it tells me it cant find
program or function exitloop wich is rathre
weird.
at line 3 i've specified the programs i want it to
run.i like it allot now i dont know if it will be
displayed if i put it in $KDEHOME/env/ because
it must be displayed in order for the user to be able
to choose

Code:
#!/bin/bash

echo "------rapid startup program-----------"

exitloop=0;                            #line 1

until  [ "$exitloop" = "1" ]; do
read choice
    if [ "$choice" = "y" ]; then
        gaim & \
        /home/stef/Desktop/firefox/firefox &\
        sylpheed &\
        dcgui-qt
        echo "rapid startup-succes"    # line3
    else 
        if [ "$choice" = "n" ]; then
        echo "nothing executed"
	exitloop=1;
        else 
        echo "error at option input"
	fi
    fi
done

echo "------terminated-----------------------"
 
Old 12-13-2005, 11:43 AM   #8
linmix
Senior Member
 
Registered: Jun 2004
Location: Spain
Distribution: FC5
Posts: 1,993
Blog Entries: 1

Rep: Reputation: 46
Quote:
Originally Posted by spx2
how can i ask for user input in the script ?
like " Do you want the programs to start ? Y/N"
and do some ifs according to this
also how do i jumpexit from a bash script ?
To have the script ask before doing something you need to use a combination of an 'if' and 'read' with echo to print the message:

Code:
echo "do you want to continue, yes or no"
read answer
if $answer=yes; then
     gaim&
fi
this will only start gaim if you type 'yes' after the question

If you want to learn more, the book in my sig (which can be downloaded free - but I like having it in paper format) and this tutorial are very useful.
 
Old 12-13-2005, 11:52 AM   #9
linmix
Senior Member
 
Registered: Jun 2004
Location: Spain
Distribution: FC5
Posts: 1,993
Blog Entries: 1

Rep: Reputation: 46
Quote:
Originally Posted by spx2
i managed to pull this non-orthodox code out...
im not too familiar yet with bash shell scripting.
i used mcedit to code it.
it seems tought that if at line 1
i put "exitloop = 0" instead of
"exitloop=0" it tells me it cant find
program or function exitloop wich is rathre
weird.
not weird at all. To declaer a variable (which is what you are doing, you need to give the value of that variable with =.- If you leave a spacve you decalere it but don't give it a value. If you did "exitloop= 0" (notice the space after =) you set thwe variable to 'space'
 
Old 12-13-2005, 11:54 AM   #10
spx2
Member
 
Registered: Dec 2005
Distribution: debian
Posts: 160

Original Poster
Rep: Reputation: 30
i already managed to do that in my last post here
have you tried my script ?
 
Old 12-13-2005, 12:35 PM   #11
linmix
Senior Member
 
Registered: Jun 2004
Location: Spain
Distribution: FC5
Posts: 1,993
Blog Entries: 1

Rep: Reputation: 46
yeah, got a bit carried away in my first post. The Until statement is nice but not necessary though. A simple 'exit 0' at the end of the script wouild have sufficed.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
small script Kassel Programming 2 11-19-2004 04:22 AM
Need help with very small script. Franklin Programming 8 10-14-2003 12:37 PM
Please Help with a small script ? juglugs Programming 2 11-14-2001 02:39 AM
Small Script msj Linux - Newbie 2 08-27-2001 06:59 AM
small script msj Programming 1 08-26-2001 11:42 AM


All times are GMT -5. The time now is 11:37 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration