Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Ubuntu User (http://www.linux-archive.org/ubuntu-user/)
-   -   services output oddity (http://www.linux-archive.org/ubuntu-user/547350-services-output-oddity.html)

Nils Kassube 07-02-2011 08:36 PM

services output oddity
 
Dave Stevens wrote:
> # service --status-all > servicesrunning.txt
> [ ? ] anacron
> [ ? ] console-screen.sh
[...]
> given the command line above I would have expected the output text to
> go into a file called servicesrunning.txt, not on screen. But the
> above output is the screen text.
>
> There IS text in the new file servicesrunning.txt, like this:
>
> dave@cl28810:~$ cat servicesrunning.txt
> [ + ] apache2
> [ + ] bind9
[...]

What you see on the screen is sent to the standard error while the
standard output is sent to your text file. If you want to have both in
the same file, use this command:

service --status-all > servicesrunning.txt 2>&1

That way the standard error is redirected to the standard output and
both are redirected to your text file.


Nils

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

Dave Stevens 07-02-2011 08:42 PM

services output oddity
 
Quoting Nils Kassube <kassube@gmx.net>:


Dave Stevens wrote:

# service --status-all > servicesrunning.txt
[ ? ] anacron
[ ? ] console-screen.sh

[...]

given the command line above I would have expected the output text to
go into a file called servicesrunning.txt, not on screen. But the
above output is the screen text.

There IS text in the new file servicesrunning.txt, like this:

dave@cl28810:~$ cat servicesrunning.txt
[ + ] apache2
[ + ] bind9

[...]

What you see on the screen is sent to the standard error while the
standard output is sent to your text file. If you want to have both in
the same file, use this command:

service --status-all > servicesrunning.txt 2>&1

That way the standard error is redirected to the standard output and
both are redirected to your text file.


Nils


yes, that works nicely, thanks very much.

Dave



--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/ubuntu-users






--
"It is no measure of health to be well adjusted to a profoundly sick society."
Krishnamurti


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

Tom H 07-02-2011 09:05 PM

services output oddity
 
On Sat, Jul 2, 2011 at 4:20 PM, Dave Stevens <geek@uniserve.com> wrote:
>
> It's handy to check that some service or other is up and running without
> necessarily invoking the service. Enter the U10.04 service command.
>
> # service --status-all > servicesrunning.txt
> *[ ? ] *anacron
> *[ ? ] *console-screen.sh
> *[ ? ] *cron
> *[ ? ] *fetchmail
> *[ ? ] *hostname
> *[ ? ] *hwclock
> *[ ? ] *hwclock-save
> *[ ? ] *keymap.sh
> *[ ? ] *killprocs
> *[ ? ] *libpam-foreground
> *[ ? ] *mailman
> *[ ? ] *module-init-tools
> *[ ? ] *modules_dep.sh
> *[ ? ] *mysql
> *[ ? ] *network-interface
> *[ ? ] *network-interface-security
> *[ ? ] *networking
> *[ ? ] *nmbd
> *[ ? ] *ondemand
> *[ ? ] *plymouth
> *[ ? ] *plymouth-log
> *[ ? ] *plymouth-splash
> *[ ? ] *plymouth-stop
> *[ ? ] *portmap
> *[ ? ] *portmap-boot
> *[ ? ] *portmap-wait
> *[ ? ] *procps
> *[ ? ] *rc.local
> *[ ? ] *saslauthd
> *[ ? ] *screen-cleanup
> *[ ? ] *sendsigs
> *[ ? ] *smbd
> *[ ? ] *stop-bootlogd
> *[ ? ] *stop-bootlogd-single
> *[ ? ] *udev
> *[ ? ] *udev-finish
> *[ ? ] *udevmonitor
> *[ ? ] *udevtrigger
> *[ ? ] *umountfs
> *[ ? ] *umountnfs.sh
> *[ ? ] *umountroot
> *[ ? ] *usermin
> *[ ? ] *vzquota
> *[ ? ] *webmin
>
> given the command line above I would have expected the output text to go
> into a file called servicesrunning.txt, not on screen. But the above output
> is the screen text.
>
> There IS text in the new file servicesrunning.txt, like this:
>
> dave@cl28810:~$ cat servicesrunning.txt
> *[ + ] *apache2
> *[ + ] *bind9
> *[ - ] *bootlogd
> *[ + ] *clamav-daemon
> *[ + ] *clamav-freshclam
> *[ - ] *dovecot
> *[ - ] *klogd
> *[ - ] *postfix
> *[ + ] *postgresql-8.4
> *[ + ] *proftpd
> *[ + ] *quota
> *[ - ] *quotarpc
> *[ - ] *rsync
> *[ - ] *sendmail
> *[ + ] *spamassassin
> *[ + ] *ssh
> *[ + ] *sysklogd
> *[ + ] *sysstat
> *[ - ] *urandom
> *[ - ] *wide-dhcpv6-client
> *[ + ] *xinetd
>
> So NOT the same text, less detail. Apparently only a summary goes into the
> text file.
>
> Anyone know why this behaviour? Why on screen, why summary only on file?

It's stderr that's displayed and stdout that's saved to "servicesrunning.txt".

If you want everything to end up in "servicesrunning.txt", you have to
run "service --status-all > servicesrunning.txt 2>&1".

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users


All times are GMT. The time now is 10:47 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.