LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 08-26-2006, 06:28 PM   #1
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
run 2 programs at the same time


i would like to run two things at the same time with 1 command:

Code:
cat hello.iso; play hello.wav
would cat and then play.

i want it to play hello.wav while it is printing hello.iso to the screen.

does anyone have a quick solution?

thanks
 
Old 08-26-2006, 06:41 PM   #2
ph0b0s
Member
 
Registered: Aug 2005
Location: Belgium
Distribution: Debian, after testing all the others!
Posts: 41

Rep: Reputation: 15
Quote:
Originally Posted by schneidz
i would like to run two things at the same time with 1 command:

Code:
cat hello.iso; play hello.wav
would cat and then play.

i want it to play hello.wav while it is printing hello.iso to the screen.

does anyone have a quick solution?

thanks
cat hello.iso & play hello.wav
 
Old 08-26-2006, 06:43 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Unix shells make it very easy to "do several things at one time." Append a '&' after any command and it becomes a "background job" of sorts: the shell "spawns" a child-task to do the command in the background. Commands such as fg and bg are useful; see info bash.

One of the basic principles in Unix environments is that you can "string together" simple commands to do complex things.
 
Old 08-26-2006, 07:01 PM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Original Poster
Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
thanks it works.

can someone tell me what this means:

Code:
cat hello.iso && play hello.wav
seems to be the same thing as:
Code:
cat hello.iso; play hello.wav
 
Old 08-26-2006, 08:17 PM   #5
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Hey, in Unix, adding one "&" somwhere can mean the difference between solving a NxN matrix equation and formatting your hard disk.

command1 && command2 means "if the exit code of command1 == 0 proceed with command2(succesful program termination)

It is in so far correct that it does the same as
command1; command2
provided command1 terminated succesfully

Try to cat a non existing file and feel the difference

jlinkels
 
Old 08-29-2006, 11:04 AM   #6
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Original Poster
Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
continued on: http://www.linuxquestions.org/questi...51#post2400451
 
  


Reply



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
Adding programs to run during boot time JonnyW247 Linux - Software 1 02-05-2006 03:52 PM
What do I need to run C++ programs ? tuxuser19 Programming 2 01-10-2006 08:48 PM
can't run any X programs Twister512 Slackware 5 01-09-2006 12:38 AM
start two programs at the same time. Brian1 Programming 16 01-01-2006 03:36 PM
how to do real time programs? frostmagic Programming 4 02-02-2004 10:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:48 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
Open Source Consulting | Domain Registration