LinuxQuestions.org
Review your favorite Linux distribution.
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 08-30-2008, 09:50 PM   #1
budhax
LQ Newbie
 
Registered: Aug 2008
Location: Switzerland - GVA
Distribution: BT3
Posts: 8

Rep: Reputation: 0
Question How to launch a command in a new window without pausing the referrer window?


Hello,
Here is my bash script below. A simple command menu.

1. From this script running in a terminal Linux window, how to launch a command (like "iwlist") in a new window without pausing the first window.

2. In KDE 3.5, how quickly to launch a script.sh script using the KDE user interface (without typing: script.sh in a window terminal)?

3. Is the first line necessary? I think it works fine without "#!/bin/bash".

Thanks in advance

CONFIG: BackTrack 3, Linux BT 2.6.21.5, KDE 3.5.7, Shell-Konsole.

Code:
#!/bin/bash
#------------------------------------------------------------------------------------ Initialisation
DFN=file
CN1=eth1
RTAP0=rtap0
MESSID=IPW22
FIP_100=192.168.1.100
FIP_101=192.168.1.101
MAC=50:41:32:23:14:05
#----------------------------------------------------------------------------------------- Functions
menu(){
	echo -- CHECK - CONFiG
	com01="iwconfig $CN1";echo  01. [$com01]
	com02="iwlist";echo  02. [$com02]
	com03="Set BSSID: [$BSSID]";echo  03. [$com03]
	echo "Choix?";read com
	case $com in
		#-- CHECK - CONFiG
		01) $com01;;
		02) $com02;;
		03) echo BSSID ?;read BSSID;;
		*) echo "BYE BYE ...";exit;;
	esac
}
#---------------------------------------------------------------------------------------------- BODY
while true;do menu
done
exit
#---------------------------------------------------------------------------------------------------

Last edited by budhax; 08-30-2008 at 10:36 PM. Reason: to add my config
 
Old 08-30-2008, 11:40 PM   #2
rocket357
Member
 
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 485
Blog Entries: 160

Rep: Reputation: 74
Quote:
Originally Posted by budhax View Post
Hello,
Here is my bash script below. A simple command menu.

1. From this script running in a terminal Linux window, how to launch a command (like "iwlist") in a new window without pausing the first window.
iwlist & # <~~ the "&" basically tells bash "run this as a daemon, not in the foreground"

Quote:
Originally Posted by budhax View Post
2. In KDE 3.5, how quickly to launch a script.sh script using the KDE user interface (without typing: script.sh in a window terminal)?
Link a desktop icon to it? I'm not sure I understood the question, but since you're using KDE you might as well...

Quote:
Originally Posted by budhax View Post
3. Is the first line necessary? I think it works fine without "#!/bin/bash".
Ok, quick lesson on magic numbers (www.google.com for more info on magic numbers)...each file has a "magic number" that tells the shell/kernel/etc... what kind of file it is. If the first few bytes contain "ELF", then it's a compiled binary. If the first characters are "#!", then the characters immediately following tell the shell what program to use to interpret the script. "#!/bin/bash" would use /bin/bash, "#!/usr/bin/env python" would use the python interpreter found on the PATH, etc...
 
Old 08-31-2008, 08:19 PM   #3
budhax
LQ Newbie
 
Registered: Aug 2008
Location: Switzerland - GVA
Distribution: BT3
Posts: 8

Original Poster
Rep: Reputation: 0
Thank you rocket357,
but how to keep the new terminal window open? It close immediately after the command "iwlist" is executed?

OK I found those commands (keeping the new window open).
Code:
xterm -e "iwlist; bash"
xterm -hold -e "iwlist"
but they block the first window.

I would open a new terminal window executing a command (and stay open) AND let the first window continu and display a new prompt immediately after the new window is open.

Thanks

Last edited by budhax; 08-31-2008 at 08:23 PM.
 
Old 08-31-2008, 11:01 PM   #4
rocket357
Member
 
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 485
Blog Entries: 160

Rep: Reputation: 74
Quote:
Originally Posted by budhax View Post
Thank you rocket357,
but how to keep the new terminal window open? It close immediately after the command "iwlist" is executed?

OK I found those commands (keeping the new window open).
Code:
xterm -e "iwlist; bash"
xterm -hold -e "iwlist"
but they block the first window.

I would open a new terminal window executing a command (and stay open) AND let the first window continu and display a new prompt immediately after the new window is open.

Thanks
You can do this:
Code:
xterm -hold -e "iwlist" &
This will open a new window *as a daemon* (i.e. not in the foreground), which will return control to the original script without closing the xterm.

Last edited by rocket357; 08-31-2008 at 11:02 PM.
 
  


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
Trying to launch a new term window while executing a bash script in that window sfmadmax Linux - Newbie 5 12-09-2007 01:34 PM
Problem with wine trying to launch a window Freex Linux - Desktop 6 02-23-2007 09:46 PM
X Window won't fully launch Blitzkreig75 Slackware 7 02-16-2007 06:41 PM
How do I launch Steam in a Window? Hoagie Linux - Games 2 05-18-2004 06:04 PM
How does one launch programs 'out of process' in a terminal window? DKnight Linux - General 5 06-07-2003 10:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:03 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration