LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-29-2004, 03:56 AM   #1
Nice-n-Slow
LQ Newbie
 
Registered: May 2004
Posts: 24

Rep: Reputation: 15
opening new bash tabs or consoles from a script


I have a very simple script that runs a program called streamripper. What it does is record streaming audio. One of the nice features about the command line version of this program is that you can see what is being recorded in your console.
The tricky part is that I like to start several copies of this program in different tabs of a tabbed Konsole session. How can I make a script that will open each instance in its own tab?
Alternately, if Konsole tabs are problematic how about running them in their own shells?
Thanks
 
Old 06-29-2004, 08:02 AM   #2
fluppi
Member
 
Registered: Oct 2003
Location: Switzerland (Europe)
Distribution: OpenSuSE, RedHat, Knoppix, IRIX + MacOSX
Posts: 198

Rep: Reputation: 30
To open a Xterminal window and give it a job, type "xterm -e sleep 5 &".

But I have doubts to open an audio device more than once ?

Hth
Fluppi
 
Old 06-29-2004, 01:36 PM   #3
Nice-n-Slow
LQ Newbie
 
Registered: May 2004
Posts: 24

Original Poster
Rep: Reputation: 15
I think I better be a little more specific about how this works. I tried your advice in a way, but it didn't seem to do what I was looking for. Let me elaborate on how this goes.

Oh yeah, and just to keep things straight, the program itself has nothing to do with any audio devices. It just happens to be recording an audio stream but it may as well be a log file. All the program does is record bits to the disk. There is no audio device to be concerned with. In fact, I can run multiple instances by opening separate terminals and running them manually so it is definitely possible to do. There is no question that it works, I just want to start it more quickly.

The script is very simple, it is as follows:
Here's an example of a single script that would start recording in a console window.


Code:
#!/bin/bash
/path/program_name options stream_URL output_path
Now, when I invoke the name of that simple one line bash script, it will start the program in a console and the console will slowly fill up with data showing what was recorded. Again, this is not much different than a log file.

Manually, it is not a problem to start multiple consoles or tabbed konsole windows and then type in a series of different streams. Having multiple instances is absolutely not a problem.

However, when I want to put all of these little one line scripts into a longer one so that I don't have to manually open so many console windows and type the names of these one-line scripts, that's where I run into problems.

Here is what I tried to do.


Code:
#!/bin/bash
/path/program_name options stream_URL-1 output_path-1
/path/program_name options stream_URL-2 output_path-2
/path/program_name options stream_URL-3 output_path-3
/path/program_name options stream_URL-4 output_path-4
But naturally, what happen is the first one starts to run and since it doesn't end, the other ones never start.

So, I took your advice and added the command you mentioned like so. . .


Code:
#!/bin/bash
xterm -e sleep 5 &
/path/program_name options stream_URL-1 output_path-1
xterm -e sleep 5 &
/path/program_name options stream_URL-2 output_path-2
xterm -e sleep 5 &
/path/program_name options stream_URL-3 output_path-3
xterm -e sleep 5 &
/path/program_name options stream_URL-4 output_path-4
But, although that popped up a dialogue that said "sleep" that quickly disappeared, it didn't change the basic problem of starting the subsequent steams in new consoles.
 
Old 06-29-2004, 02:10 PM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,481

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
xterm -e "/path/program_name options stream_URL-1 output_path-1"&
would do better
 
Old 06-30-2004, 07:58 AM   #5
Nice-n-Slow
LQ Newbie
 
Registered: May 2004
Posts: 24

Original Poster
Rep: Reputation: 15
Yeska! Thanks, that is sweet. I'm so impressed.
And not that it is essential, but how about other types of terminals like a kshell and how about tabbed instead of each in its own window?
It's not important really, but out of curiosity I'd be interested.
 
Old 07-12-2004, 07:39 AM   #6
Nice-n-Slow
LQ Newbie
 
Registered: May 2004
Posts: 24

Original Poster
Rep: Reputation: 15
Well, I'm still not quite satisifed. I mean xterm is pretty good, but if the app ends it just shuts down. The problem with that is if I start a script with ten terminals and number seven goes down, I have to go back, find out which job terminal seven was on and then restart it manually.

In contrast, if I open up say tabbed Konsoles and manually enter the jobs, then when one goes down I can just hit the up key and restart without having to be concerned about figuring out which one it was.

What I'd really like to know is how to script up a bunch of virtual terminals on the command line as opposed to X. My system only offers four virtual terminals and I'm not sure how to increase that number, map them to hot keys and then make use of them in a script, but that would be the ultimate.
 
Old 07-12-2004, 09:10 AM   #7
Nice-n-Slow
LQ Newbie
 
Registered: May 2004
Posts: 24

Original Poster
Rep: Reputation: 15
Oops.
I forgot. I wasn't posting just to share my desires for a more refined technique. I was going to share another technique I came across and, in fact, after I posted I realized that it contained a solution to part of my problem.
The closest I've come so far is a script with a line like this.

konsole --noclose -e program_to_execute

Note, don't use quotes if you try this one. Apparently xterm wanted quotes, but konsole doesn't.

Like anybody is really interested, but I thought I'd put it up here for future reference.
 
Old 07-12-2004, 09:25 AM   #8
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,481

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
I can't help on the kconsole issue, in fact, I don't think there is a way to open a kconsole tab programmatically by say an escape sequence.

However, if your ten scripts need to run non stop, what about launching persistant xterms restarting your command like:

cmd1 shell script content:
Code:
while true
do
  /path/program_name options stream_URL-1 output_path-1
  echo -n "Program STOPPED, press return to restart it"
  read foo
done
launched by:
Code:
xterm -e /path/cmd1&
etc...
 
  


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
awk script forgets tabs iluvatar Linux - Software 2 11-04-2004 01:56 AM
Opening xterms from a script Nice-n-Slow DamnSmallLinux 2 08-15-2004 04:25 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-05-2003 11:58 PM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 05:34 AM


All times are GMT -5. The time now is 12:22 AM.

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