LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help needed with simple bash script (https://www.linuxquestions.org/questions/linux-newbie-8/help-needed-with-simple-bash-script-906091/)

clifford227 10-02-2011 02:56 PM

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?

lugoteehalt 10-02-2011 03:07 PM

Perhaps use 'sleep' to give the 10 second pause and then 'pkill' to kill the process??

colucix 10-02-2011 03:15 PM

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


clifford227 10-02-2011 04:28 PM

Quote:

Originally Posted by colucix (Post 4488317)
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 :)

linux2001 10-03-2011 10:46 AM

Good mark this thread as SOLVED


All times are GMT -5. The time now is 03:00 AM.