LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 09-22-2013, 03:43 AM   #1
123raajesh
LQ Newbie
 
Registered: Sep 2013
Posts: 12

Rep: Reputation: Disabled
linux prompt break and start


colucix,

I have a doubt is it possible to execute a series of commands with prompt.
Say

Start
Command1
Command2

stop (to verify)

Start (should not restart from 1st command)

Command3

stop (to verify)

start (should not restart from 1st or 3rd command)

Command4

end

Please suggest, thanks in advance.
 
Old 09-22-2013, 06:04 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You can simply stop the process by pressing Ctrl-Z, which is equal to send a TSTP signal (see man 7 signal for details). The process will be in a idle state until it receives a CONT signal. Since the process is sent in background upon interrupting, you can restore it by means of the fg command. Is this what you're looking for?
 
1 members found this post helpful.
Old 09-22-2013, 06:35 AM   #3
123raajesh
LQ Newbie
 
Registered: Sep 2013
Posts: 12

Original Poster
Rep: Reputation: Disabled
linux prompt break and start reply

Quote:
Originally Posted by colucix View Post
You can simply stop the process by pressing Ctrl-Z, which is equal to send a TSTP signal (see man 7 signal for details). The process will be in a idle state until it receives a CONT signal. Since the process is sent in background upon interrupting, you can restore it by means of the fg command. Is this what you're looking for?
Hi, idea same but these commands are executed through a file, there is a prompt asking user to proceed(Enter) or stop (CTRL+c). If i do this the script will end here itself say after Command2, as per my example. But, want the user to give chance to review the executed results and then user should be able to proceed from Command3, that is user has breaked at command2 and start at Command3.

Sorry if i am confusing.

Thanks
 
Old 09-24-2013, 03:24 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
If I understand well you want to give the ability to the user to interrupt a running process and proceed with the following statements in the script, is it correct?

In this case, if you want to use Ctrl-C to interrupt a single process, you have to use trap to execute a different action, otherwise the whole script will be interrupted. Then you launch the interruptible command in background and use wait to pause the script until the process has terminated OR until the user presses Ctrl-C to stop it. Example:
Code:
#!/bin/bash
#
function control_c () {
  kill -9 $pid
}

trap control_c SIGINT

command_one
command_two &
pid=$!

echo "Press Ctrl-C to stop the execution of current process..." && wait $pid

command_three &
pid=$!

echo "Press Ctrl-C to stop the execution of current process..." && wait $pid
Hope this helps.
 
  


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
Netbeans 7.3: Program does not break at break points when debugging JavaScript OtagoHarbour Programming 0 02-22-2013 02:44 AM
Can't get Ok prompt after break sequence cl_32 Solaris / OpenSolaris 3 11-09-2010 05:06 PM
anyone install erlang and tsung on linux? error prompt when start configure command vitalstrike82 SUSE / openSUSE 3 03-28-2008 10:34 PM
start with a command prompt Bashkir Linux - General 1 05-14-2001 08:29 AM
Start up files ,how to break into them ? sachin77 Linux - Newbie 1 04-24-2001 06:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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