LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 03-28-2005, 12:23 AM   #1
slpwkr
LQ Newbie
 
Registered: Mar 2005
Location: philippines
Posts: 18

Rep: Reputation: 0
How to terminate this command


Hi guys how can I terminate this command in BASH script.

$ cat /dev/ttyS0

I terminate this commad by using Ctrl c or Ctrl z. But how can I terminate this automatically?
 
Old 03-28-2005, 12:52 AM   #2
zeropash
Member
 
Registered: Apr 2003
Location: Bangalore,India
Distribution: FC2, RHES, RH9, FC3, FC1, Slackware 3.0
Posts: 208

Rep: Reputation: 30
kill -HUP pid ?
 
Old 03-28-2005, 03:33 AM   #3
slpwkr
LQ Newbie
 
Registered: Mar 2005
Location: philippines
Posts: 18

Original Poster
Rep: Reputation: 0
Can't do that because the command:

$ cat /dev/ttyS0

will be put into a script file. like this one

!#/bin/sh

$ cat /dev/ttyS0

And I will run script file it cron like every 1 minute. If I will use ps and kill. It will be very complocated because every process has different ps id. I just want to cat and redirect the /dev/ttyS0 every 1 minute but "cat /dev/ttyS0" never stops.
 
Old 03-28-2005, 05:35 AM   #4
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Execute it in background like :
Code:
cat /dev/ttyS0 &
pid=$!

# wait some time
sleep 2

echo "Now I kill cat /dev/ttyS0"
kill $pid
 
Old 03-28-2005, 11:33 AM   #5
skie_knite007
Member
 
Registered: Dec 2004
Location: India
Distribution: Fedora Core 4
Posts: 145

Rep: Reputation: 15
U can juz use ctrl+ C

or use ps -ax command to kno the process id of the program
Suppose the process ID is 2848.
Now type kill 2648 (from other terminal as root) and the program will be terminated
 
  


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
terminate the connection ust Linux - General 1 03-19-2005 10:07 AM
How to terminate X application? drj000 Linux - Software 1 02-10-2005 07:40 PM
how to terminate processes feetyouwell Programming 8 09-18-2004 02:27 PM
How can I terminate an application? yangyiqi Linux - Software 7 12-10-2003 06:39 PM
Command to terminate X Window smoothly soda Linux - General 1 11-29-2002 06:54 AM

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

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