LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 10-02-2011, 03:56 PM   #1
clifford227
Member
 
Registered: Dec 2009
Distribution: Slackware 14
Posts: 282

Rep: Reputation: 64
Help needed with simple bash script


Hi,

How would I write a script that displays a jpg using xv (I know this part), and then after 10 seconds closes xv, so that bash moves on to the next line of the script?
 
Old 10-02-2011, 04:07 PM   #2
lugoteehalt
Senior Member
 
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Blog Entries: 2

Rep: Reputation: 49
Perhaps use 'sleep' to give the 10 second pause and then 'pkill' to kill the process??
 
Old 10-02-2011, 04:15 PM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Try to launch the process in background, retrieve the Process ID using $!, sleep 10 seconds then kill it:
Code:
xv file.jpg &
pid=$!
sleep 10 && kill -9 $pid
 
Old 10-02-2011, 05:28 PM   #4
clifford227
Member
 
Registered: Dec 2009
Distribution: Slackware 14
Posts: 282

Original Poster
Rep: Reputation: 64
Quote:
Originally Posted by colucix View Post
Try to launch the process in background, retrieve the Process ID using $!, sleep 10 seconds then kill it:
Code:
xv file.jpg &
pid=$!
sleep 10 && kill -9 $pid
That worked perfectly, thanks guys
 
Old 10-03-2011, 11:46 AM   #5
linux2001
Member
 
Registered: Sep 2011
Posts: 32

Rep: Reputation: Disabled
Good mark this thread as SOLVED
 
0 members found this post helpful.
  


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
'simple' script help needed (start/stop program) powadha Linux - Software 1 03-26-2009 02:44 PM
simple script needed for file renaming frankkky Programming 8 09-20-2008 11:19 AM
simple shell script help needed vbsaltydog Linux - Networking 10 05-02-2006 02:47 AM
simple script needed drum2jc Linux - Software 1 01-05-2006 01:28 AM
simple backup script needed ferret_dude Programming 4 05-24-2004 09:45 AM


All times are GMT -5. The time now is 06:49 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration