Find the answer to your Linux question:
Results 1 to 5 of 5
I'm booting a linux system using bootloader uboot which loads kernel and initrd and then starts the kernel, the kernel finally starts initrd. I now want to sent the output ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2012
    Posts
    4

    Redirect output from initrd both to console and file


    I'm booting a linux system using bootloader uboot which loads kernel and initrd and then starts the kernel, the kernel finally starts initrd. I now want to sent the output from the commands of my /linuxrc both to the serial console (this is working, probably from the "console=/dev/ttyS0" kernel parameters) AND to a file.

    I'm quite sure that some simple "exec M>&N" commands within linuxrc are sufficient but does not manage to figure them out. Can somebody provide some help?

    Thanks,
    Ruediger

  2. #2
    Just Joined!
    Join Date
    Apr 2012
    Posts
    4
    Oh, i forgot one additional condition: i want to redirect both stdout and stderr.


    Quote Originally Posted by Ruediger View Post
    I'm booting a linux system using bootloader uboot which loads kernel and initrd and then starts the kernel, the kernel finally starts initrd. I now want to sent the output from the commands of my /linuxrc both to the serial console (this is working, probably from the "console=/dev/ttyS0" kernel parameters) AND to a file.

    I'm quite sure that some simple "exec M>&N" commands within linuxrc are sufficient but does not manage to figure them out. Can somebody provide some help?

    Thanks,
    Ruediger

  3. #3
    Linux Newbie
    Join Date
    Nov 2009
    Posts
    222
    Ruediger,

    try "command-name &>file" or "command > file-name 2>&1"

    Cheers - VP

  4. #4
    Just Joined!
    Join Date
    Apr 2012
    Posts
    4
    Thanks VP, but this does not meet my requirement, i think.

    Debug-output of initrd init-process "linuxrc" should be redirected; this is started from kernel command line defined by uboot via option "init=/linuxrc". So i think i do not have the option to use the redirection commands you suggested.

    I think i just require the possibily to redirect stdout and stderr to some file (and still gain the output on my serial console) from within my bash script. Main mechanisms seem to be described at tldp.org/LDP/abs/html/io-redirection.html, but i do not manage to build a complete solution.

    Ruediger

  5. #5
    Just Joined!
    Join Date
    Apr 2012
    Posts
    4
    Quote Originally Posted by Ruediger View Post
    Oh, i forgot one additional condition: i want to redirect both stdout and stderr.
    Well, i think i found a feasible solution for my problem at unix.com/unix-dummies-questions-answers/23497-how-output-results-command-properly.html: redirection of subshell output.

    So my script will look as follows to redirect it's output:

    ...
    (
    some-commands
    ) 2>&1 | tee -a logfile

Posting Permissions

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