LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 11-05-2003, 09:33 AM   #1
cleaner416
LQ Newbie
 
Registered: Sep 2003
Posts: 11

Rep: Reputation: 0
Question Shell script to kick off two apps simultaneously


Hi,

I am working on a small photography project. The goal is to take a snapshot with two cameras at the exact same instant. The camera shutters are triggered through a *nix command line application. So what I need to do is write a bash script that fires two instances of the app at the *exact* same time. Is there an easy way to do this through a bash script? Should I write a C prog instead? Any suggestions apreciated!

Thanks!

Last edited by cleaner416; 11-05-2003 at 11:29 AM.
 
Old 11-05-2003, 11:53 AM   #2
LogicG8
Member
 
Registered: Jun 2003
Location: Long Island, NY
Distribution: Gentoo Unstable (what a misnomer)
Posts: 380

Rep: Reputation: 30
There is no way to do it at the *exact* same time
although you can come really close. A computer can
only execute one process at a time unless you have
multiple processors.

I wrote this really simple script to demonstrate
how to run the 2 programs concurrently
This will out put the same time/date

#!/bin/sh

date &
date
 
Old 11-05-2003, 12:52 PM   #3
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
Putting the ampersand after a command runs it in background, the command interpreter goes on to process the next command.

On a fast PC the difference is going to be less than 1000th of a second (1 ms) between instance #1 and instance #2. If you're using a strobe, then you'll have to do something to turn off the thyristor so you get maximum burn time.

If I get what you want, consider --

tee

you can have output simultaneous output to more than one device. Like a port that triggers a shutter maybe

Code:
mycommandfile | tee /dev/something | tee /dev/somethingelse > /dev/null
The /dev/null is capturing output that goers to the screen

The example above (from LogicG8) will have to be in a script file.
 
Old 11-05-2003, 01:17 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
You could also try scheduling with "at".
 
Old 11-05-2003, 08:55 PM   #5
cleaner416
LQ Newbie
 
Registered: Sep 2003
Posts: 11

Original Poster
Rep: Reputation: 0
Thanks for all of your suggestions. I'll experiment and post the results.

Still trying to figure out how get my keyspan usb->serial converter to bheave properly, but that is a story for another thread...
 
  


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
Shell script inside shell script treotan Linux - General 4 02-19-2009 06:34 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 03:00 PM

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

All times are GMT -5. The time now is 04:36 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