Find the answer to your Linux question:
Results 1 to 3 of 3
What I am trying to do is write a script that will execute a few processes running in the background. This part is easy enough. However, what I want to ...
  1. #1
    Just Joined!
    Join Date
    Aug 2007
    Posts
    2

    Switch a process to foreground by PID?

    What I am trying to do is write a script that will execute a few processes running in the background. This part is easy enough. However, what I want to do after that at some point is switch these to the foreground so I can give input through the keyboard. However, when I do the 'jobs' command, these processes do not appear, though they do appear when I do 'ps'.

    So basically, what I want to do is bring a process to the foreground by using its PID. Is this possible, or is there another way around this?

    Thanks for your replies.

  2. #2
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    Hi,

    The script which started the others processes is running in another shell and you can only manage background processes which started in the current shell.
    Try to run the script in the current shell as follow:

    Code:
    . ./scriptname
    instead of:

    Code:
    ./scriptname
    Regards

  3. #3
    Just Joined!
    Join Date
    Aug 2007
    Posts
    2
    Hi Franklin, what you said worked perfectly. Thanks a lot!

    A note for anyone else who had this problem (someone else please correct me if necessary) - at first I had "permission denied" when I tried this, but when I ran another shell within my current one, and ran the script from there, I had no problems.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...