#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2006
    Posts
    29
    Rep Power
    0

    Question Chain/concatenate stdout


    Consider this pseudo-code:
    Code:
    cat `syslogreporter` `df -h` | mailx -s "Periodic Report" hotaru
    What I want to do is run >=2 commands in series for a single stream to mailx. I already tried to
    Code:
    echo `cmd1` `cmd2`
    but then I lose newlines.
    I know I can accomplish this with Python, but can I do it in bash alone?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,395
    Rep Power
    1688
    You are taking the outputs of two commands and wanting to pass them forward - don't use cat for that!

    Try:

    Code:
    echo "`syslogreporter` `df -h`" | mailx -s "Periodic Report" hotaru
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    1
    Rep Power
    0
    Code:
    (syslogreporter && df -h) | mailx -s "Periodic Report" hotaru

IMN logo majestic logo threadwatch logo seochat tools logo