LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-29-2006, 01:19 AM   #1
nny0000
Member
 
Registered: Aug 2003
Distribution: Slackware, Ubuntu
Posts: 158

Rep: Reputation: 30
bash script


I am trying to run shoutcast from a shared server running debian.

In order for it to work I need to run one program after another.

I need to run one program than sleep for 5 seconds than run the other.

The pipe (|) is useless and && is does not help since the second program needs the first. Is their a way to create this script

#!/bin/bash

program 1 (does not have a silent mode and relay's data to std output)
sleep 5
program 2 (needs program 1)

Thanks
 
Old 07-29-2006, 02:10 AM   #2
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
prog1 | (sleep 5 ; prog2) ?
 
Old 07-29-2006, 02:34 AM   #3
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
prog1 | {sleep 5 ; prog2} ?
 
Old 07-29-2006, 02:45 AM   #4
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
you can also use named pipes. do 'mkfifo ... namedpipe'. then

Code:
prog1 > namedpipe &
sleep 5
prog2 < namedpipe
and also using process' file descriptors. i'm not sure if this really works:

Code:
prog2 < <(prog1; sleep 5)
 
Old 07-29-2006, 02:52 AM   #5
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
nny0000, I understand that the second program doesn't need the output of program 1, it just needs that program to be running? Then I'd suggest almost literally what you wrote already:
Code:
#! /bin/bash
program 1 &
sleep 5
program 2
The output of program 1 will be ignored. The "&" starts program 1 in the background, so that immediately after its start, the shell will continue with the next command.
 
Old 07-29-2006, 03:42 AM   #6
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
In this case, don't forget to append '&>/dev/null' before '&' :
program1 &>/dev/null &
 
Old 07-29-2006, 05:35 PM   #7
nny0000
Member
 
Registered: Aug 2003
Distribution: Slackware, Ubuntu
Posts: 158

Original Poster
Rep: Reputation: 30
Thanks for all the help
 
Old 07-29-2006, 06:29 PM   #8
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
I see that cryptography's ideas go to masses. We are sure we have answered the question correctly though we are not sure what the question was. 42.
 
Old 07-29-2006, 06:37 PM   #9
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 680Reputation: 680Reputation: 680Reputation: 680Reputation: 680Reputation: 680
Maybe his shoutcast program is titled: The Hitchhiker's Guide to Linux
 
  


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
building a bash script from an install script paranoid times Programming 6 07-29-2006 03:24 AM
Bash script - executing a script through subdirectories bubkus_jones Programming 5 04-24-2006 05:05 PM
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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

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
Open Source Consulting | Domain Registration