Results 1 to 6 of 6

Thread: BASH - service --status-all

Hybrid View

  1. #1
    Join Date
    May 2012
    Location
    a planet far away
    Beans
    34
    Distro
    Ubuntu Studio 12.04 Precise Pangolin

    BASH - service --status-all

    the following cmd generates a .txt with a partial listing of running services on my system:

    service --status-all > services.txt | gedit& services.txt

    I cannot remember exactly how load the text file with the complete listing. any suggestions? I'm looking for a one linerer....

  2. #2
    Join Date
    Apr 2012
    Beans
    7,256

    Re: BASH - service --status-all

    I'm not sure I understand what you're asking, but iirc the services whose status can't be determined (the ones shown with [ ? ] alongside) go to stderr instead of stdout - so if you want to capture those to the file as well you would need something like

    Code:
    service --status-all > services.txt 2>&1
    or (in newer versions of bash only)

    Code:
    service --status-all &> services.txt

  3. #3
    Join Date
    May 2012
    Location
    a planet far away
    Beans
    34
    Distro
    Ubuntu Studio 12.04 Precise Pangolin

    Re: BASH - service --status-all

    perfect! the 2>@1 is the (passing cmdline params to apps) is the part I didn't quite get. I'm going to experiment...stay tuned...

  4. #4
    Join Date
    May 2012
    Location
    a planet far away
    Beans
    34
    Distro
    Ubuntu Studio 12.04 Precise Pangolin

    Re: BASH - service --status-all

    now all the services appear but its not opening the services.txt. can you explain why
    service --status-all &> services.txt
    requires the &? whats the difference btw 2>&1 and &>? It craps out when I try piping it directly to gedit using the following cmd: service --status-all &> services.txt | gedit "services.txt"

  5. #5
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: BASH - service --status-all

    This would be a one-liner
    Code:
     service --status-all &>services.txt; less services.txt
    edit: or even better if you need not save a file
    Code:
    service --status-all &> /dev/stdout|less
    Last edited by sudodus; March 14th, 2013 at 11:42 AM.

  6. #6
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: BASH - service --status-all

    Quote Originally Posted by RaHorakhty View Post
    can you explain why requires the &? whats the difference btw 2>&1 and &>?
    &>file is a bash-specific shortcut for >file 2>&1. As to what all this means, please have a look at Illustrated Redirection Tutorial.
    Last edited by schragge; March 15th, 2013 at 03:17 PM.

Bookmarks

Posting Permissions

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