Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello.
I like to move a command to background and I found "bg" and "fg" commands but I like when I move command to background then its running and not show me the result suddenly when its finished. For exmaple:
Code:
$ sudo nmap -A IP
$ bg
[1]+ sudo nmap -A IP &
In above example, when the nmap command finished then it show the result in the terminal suddenly.
Hello.
I like to move a command to background and I found "bg" and "fg" commands but I like when I move command to background then its running and not show me the result suddenly when its finished. For exmaple:
Code:
$ sudo nmap -A IP
$ bg
[1]+ sudo nmap -A IP &
In above example, when the nmap command finished then it show the result in the terminal suddenly.
Thank you.
That is not quite how background works. You could background it using the command-line
Code:
sudo nmap -A IP &
and get an effect something like that. Several of the other ways to background detach the process from the terminal so you need to redirect the output.
To use bg and fg you need to run the process, then CRTL-Z to stop the process and regain control, then bg will push it into the background. fg would recover it to the foreground. Easier to just start it in the background if that is your intent (or use screen).
All of this information and more is readily available at dozens of sites online. a search with duckduckgo, google, bing, or evn yahoo search would turn up tutorials and references.
I do not really understand what do you want to do with your command if you do not want to see the result.
By default nmap scans the net and reports the result. If you suppress the result you will lost it.
You ought to read about redirection to save the output (see man bash).
(or probably I misunderstood something?)
That is not quite how background works. You could background it using the command-line
Code:
sudo nmap -A IP &
and get an effect something like that. Several of the other ways to background detach the process from the terminal so you need to redirect the output.
To use bg and fg you need to run the process, then CRTL-Z to stop the process and regain control, then bg will push it into the background. fg would recover it to the foreground. Easier to just start it in the background if that is your intent (or use screen).
All of this information and more is readily available at dozens of sites online. a search with duckduckgo, google, bing, or evn yahoo search would turn up tutorials and references.
Excuse me, I forgot to show the full command:
Code:
$ sudo nmap -A
Starting Nmap 6.47 ( http://nmap.org ) at 2017-09-02 15:06 PDT
^Z
[1]+ Stopped sudo nmap -A IP
When I did "command &" then it cause some problem. for example, run "ping google.com &".
so that it terminates after three packets and you would get the output when ping exits. The more general case would require you to redirect STDOUT and STDERR and examine them later.
The best case is to use something like screen (I like to handle it with screenie) so my command is running in a different virtual terminal session and I can go look at the output at my leisure. Is there anything that prevents you from using such a solution?
I do not really understand what do you want to do with your command if you do not want to see the result.
By default nmap scans the net and reports the result. If you suppress the result you will lost it.
You ought to read about redirection to save the output (see man bash).
(or probably I misunderstood something?)
I need something like switch. when the nmap finished then I switch to it and see the result.
so that it terminates after three packets and you would get the output when ping exits. The more general case would require you to redirect STDOUT and STDERR and examine them later.
The best case is to use something like screen (I like to handle it with screenie) so my command is running in a different virtual terminal session and I can go look at the output at my leisure. Is there anything that prevents you from using such a solution?
"ping" command is a problem and I see the result and even can't stop it. I used "kill" command for stop it
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.