Linux (Bash?) Equivalent of OS/2 "Detach" and "Start" Commands?
I'm looking for the bash equivalents of two OS/2 command line features for running programs, "Start" and "Detach". I am probably missing the obvious, but I don't see the equivalent in the bash man pages. Under OS/2, running "start program.exe" from a command prompt launched the application and freed up the command prompt for additional input immediately. Like in Linux, if you just ran "program.exe" at a command prompt, you no longer had use of the command prompt until you exited the program. Similarly, "detach program.exe" also launched the program and gave the user immediate access to the command prompt. But "detach" was used only for those programs that did not require any keyboard or mouse input, nor any screen output, to run. Under Windows, this would be called "Run as a Service." Are there Linux equivalents to these commands? TIA, Mark -- ___________________________________________________________________ A Message From... L. Mark Stone http://www.lmstone.com
On Sunday 30 March 2003 7:32 am, L. Mark Stone wrote:
I'm looking for the bash equivalents of two OS/2 command line features for running programs, "Start" and "Detach". I am probably missing the obvious, but I don't see the equivalent in the bash man pages.
Under OS/2, running "start program.exe" from a command prompt launched the application and freed up the command prompt for additional input immediately. Like in Linux, if you just ran "program.exe" at a command prompt, you no longer had use of the command prompt until you exited the program.
For start: <program> & The '&' puts it in the background.
Similarly, "detach program.exe" also launched the program and gave the user immediate access to the command prompt. But "detach" was used only for those programs that did not require any keyboard or mouse input, nor any screen output, to run. Under Windows, this would be called "Run as a Service."
Are there Linux equivalents to these commands?
TIA, Mark
Think '&' would also work in this case. -- +----------------------------------------------------------------------------+ + Bruce S. Marshall bmarsh@bmarsh.com Bellaire, MI 03/30/03 07:37 + +----------------------------------------------------------------------------+ "You never really learn to swear until you learn to drive."
On Sun, 30 Mar 2003, L. just had to get this off his chest:
I'm looking for the bash equivalents of two OS/2 command line features for running programs, "Start" and "Detach". I am probably missing the obvious, but I don't see the equivalent in the bash man pages.
Under OS/2, running "start program.exe" from a command prompt launched the application and freed up the command prompt for additional input immediately. Like in Linux, if you just ran "program.exe" at a command prompt, you no longer had use of the command prompt until you exited the program.
Similarly, "detach program.exe" also launched the program and gave the user immediate access to the command prompt. But "detach" was used only for those programs that did not require any keyboard or mouse input, nor any screen output, to run. Under Windows, this would be called "Run as a Service."
Are there Linux equivalents to these commands?
The foreground and background process uses and commands have been explained already. SuSE also has the "startproc" and "killproc" commands to force a process to the background or end it. These would I think be equivelant to OS/2s detach. See 'man startproc' Theo -- Theo v. Werkhoven Registered Linux user# 99872 http://counter.li.org ICBM 52 13 27N , 4 29 45E. SuSE 8.0 x86 Kernel k_Athlon 2.4.19-4GB See headers for PGP/GPG info.
On 30-Mar-03 L. Mark Stone wrote:
I'm looking for the bash equivalents of two OS/2 command line features for running programs, "Start" and "Detach". I am probably missing the obvious, but I don't see the equivalent in the bash man pages.
Under OS/2, running "start program.exe" from a command prompt launched the application and freed up the command prompt for additional input immediately. Like in Linux, if you just ran "program.exe" at a command prompt, you no longer had use of the command prompt until you exited the program.
Similarly, "detach program.exe" also launched the program and gave the user immediate access to the command prompt. But "detach" was used only for those programs that did not require any keyboard or mouse input, nor any screen output, to run. Under Windows, this would be called "Run as a Service."
Are there Linux equivalents to these commands?
TIA, Mark
While not familiar with these OS/2 commands, from what you say above
it looks as though "start" is used to launch a program which requires
input to itself in its own window, while at the same time freeing up
the command line for further independent use by the user, while
"detach" launches a program which does not expect any further input
from the user and also at the same time frees up the command line.
In both cases, in Linux (and in Unix generally) the key to this is
the command-line use of the symbol "&".
In its simplest case, corresponding to what I have said about "detach"
above, you would enter the following onto the command line (assuming
the program you want to run is called "program1"):
program1 &
This will start "program1" running and detach it from the command
line which started it. You will then get the command-line prompt
back, and can use it quite independently for other purposes.
This can also be used for programs which open their own separate
windows for input once started. "program1 &" will start up the program,
detach it from the command line, and the program itself will look after
opening its own windows as needed.
On the other hand, if "program1" expects its input to come from the
window/terminal _within_ which it is running, then you will need
(under X windows) to explicitly open a separate window to run it in.
Example:
xterm -e vim myfile &
will open a new X window, enclosing an "xterm", within which vim will
start up, opening the file "myfile" for editing, and (because of the "&")
all this will again be detached from the originating command line. In this
case it is strictly speaking the program "xterm" which gets detached;
the program "vim" hangs off "xterm", so to speak, and the "xterm"
will stay alive so long as the program which depends on it is still
in use. The moment you finish with your "vim" session, closing the
document you are editing and quitting "vim", the "xterm" will also
close down.
This use of "&" in known in the Unix world as "putting a process
in the background". There are two associated commands: "bg" and "fg"
(see "help bg" and "help fg" if running the bash shell).
If a job has been put in the background (e.g. by using "&") after
the command (say):
program1 &
you will see a job-number in [...] and process-id as soon as your
command-lie prompt returns, e.g.
xterm &
[1] 5314
If you now did
fg 1
you would re-attach the program (in this case "xterm") to the
command line (though in this case, where the program is "xterm",
nothing interesting would happen, except that the command-line
would no longer accept independent input). Often, typing Ctrl-Z at
a program which is running in the foreground will put it in the
background, liberating the command-line, with a message like
[1]+ Stopped xterm
It could then be brought back to the foreground with "fg 1".
I hope this helps!
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding)
On Sun, 30 Mar 2003 Ted.Harding@nessie.mcc.ac.uk wrote:
This use of "&" in known in the Unix world as "putting a process in the background". There are two associated commands: "bg" and "fg" (see "help bg" and "help fg" if running the bash shell).
If a job has been put in the background (e.g. by using "&") after the command (say):
program1 &
you will see a job-number in [...] and process-id as soon as your command-lie prompt returns, e.g.
xterm & [1] 5314
If you now did
fg 1
you would re-attach the program (in this case "xterm") to the command line (though in this case, where the program is "xterm", nothing interesting would happen, except that the command-line would no longer accept independent input). Often, typing Ctrl-Z at a program which is running in the foreground will put it in the background, liberating the command-line, with a message like
[1]+ Stopped xterm
It could then be brought back to the foreground with "fg 1".
Also of interest is the program screen. -- (o< //\ Powered by SuSE Linux V_/_ Virusproof. Crashproof. 9:13am up 34 days, 12:16, 27 users, load average: 2.52, 1.75, 1.38 processes 21528243
On Sun, 2003-03-30 at 09:06, Ted.Harding@nessie.mcc.ac.uk wrote: <snip> Ted, That is EXACTLY what I was looking for! Thank you SO MUCH for the clear explanation! Best regards, Mark -- ___________________________________________________________________ A Message From... L. Mark Stone http://www.lmstone.com
On Sunday 30 March 2003 15:06, Ted Harding wrote: <SNIP>
On the other hand, if "program1" expects its input to come from the window/terminal _within_ which it is running, then you will need (under X windows) to explicitly open a separate window to run it in. Example:
xterm -e vim myfile &
will open a new X window, enclosing an "xterm", within which vim will start up, opening the file "myfile" for editing, and (because of the "&") all this will again be detached from the originating command line. In this case it is strictly speaking the program "xterm" which gets detached; the program "vim" hangs off "xterm", so to speak, and the "xterm" will stay alive so long as the program which depends on it is still in use. The moment you finish with your "vim" session, closing the document you are editing and quitting "vim", the "xterm" will also close down.
Can this be achieved on a text console, I imagine causing a program to start on a different console? So that I can issue a command on console 1 and have the program start in console 2. Would I have to already be logged in to this console? Dylan -- It is a dark day...
On Sunday 30 March 2003 15:06, Ted Harding wrote: <SNIP>
On the other hand, if "program1" expects its input to come from the window/terminal _within_ which it is running, then you will need (under X windows) to explicitly open a separate window to run it in. Example:
xterm -e vim myfile &
will open a new X window, enclosing an "xterm", within which vim will start up, opening the file "myfile" for editing, and (because of the "&") all this will again be detached from the originating command line. In this case it is strictly speaking the program "xterm" which gets detached; the program "vim" hangs off "xterm", so to speak, and the "xterm" will stay alive so long as the program which depends on it is still in use. The moment you finish with your "vim" session, closing the document you are editing and quitting "vim", the "xterm" will also close down.
Can this be achieved on a text console, I imagine causing a program to start on a different console? So that I can issue a command on console 1 and have the program start in console 2. Would I have to already be logged in to this console? Yes and no. Assume that tty2 is the command console 2. vim myfile < /dev/tty2 > /dev/tty2 2>&1 & If you are not logged on, you will get a permission denied error. If you are logged on, it will happily start vim, but it will interleave
On Sun, 30 Mar 2003 15:29:09 +0100
Dylan
On Sun, 30 Mar 2003, Ted just had to get this off his chest:
On 30-Mar-03 L. Mark Stone wrote:
I'm looking for the bash equivalents of two OS/2 command line features for running programs, "Start" and "Detach". I am probably missing the obvious, but I don't see the equivalent in the bash man pages. [..] would no longer accept independent input). Often, typing Ctrl-Z at a program which is running in the foreground will put it in the background, liberating the command-line, with a message like
[1]+ Stopped xterm
It could then be brought back to the foreground with "fg 1".
I didn't read this completely before, therefor my late reply now. This bit from Ted is not correct. SIGSTOP does /not/ put a process into background, it does what it says; it stops a process, i.e. the process doesn't use CPU time, while a process in the background (by '&' or 'bg') is of course still running. You mostly use SIGSTOP to free a console by doing 'bg' after the process stopped. See man 7 signal Theo -- Theo v. Werkhoven Registered Linux user# 99872 http://counter.li.org ICBM 52 13 27N , 4 29 45E. SuSE 8.0 x86 Kernel k_Athlon 2.4.19-4GB See headers for PGP/GPG info.
On Sunday 30 March 2003 12:32 pm, L. Mark Stone wrote:
I'm looking for the bash equivalents of two OS/2 command line features for running programs, "Start" and "Detach". I am probably missing the obvious, but I don't see the equivalent in the bash man pages.
I don't know the programs you are talking about in terms of OS/2, but I use "screen" for running jobs that may require text input at some later date. I use screen when running mutella [A gnucleus/etc style p2p fileshare client/server] screen mutella [This opens up the program in the current shell] ctrl+a d [This detaches the shell and returns the prompt] If I want to get back to it, I can run screen -r [ -r is reattach] The program runs in the background quite happily in my experience. YMMV :o) Hope this helps! Jon
participants (8)
-
Bruce Marshall
-
Dylan
-
Jerry Feldman
-
L. Mark Stone
-
Robt. Miller
-
Ted.Harding@nessie.mcc.ac.uk
-
The Purple Tiger
-
Theo v. Werkhoven