Note that there are some explanatory texts on larger screens.

plurals
  1. POPiping to a command in Ash Shell
    primarykey
    data
    text
    <p>I wrote a bash script to send an email using telnet. I'm installing it on a TS-7260 running busyBox (which has an ash shell).</p> <p>Something is different between Bash and Ash and I can't figure out why the following won't work. It's got to be something with the way I'm piping the echos to telnet. Here's the script:</p> <pre><code>#!/bin/ash # Snag all the error messages from a given date, open a telnet connection to an outgoing mail server, stick the logs in an email, and send it. # Tue Jul 2 14:06:12 EDT 2013 # TMB # Tue Jul 9 17:12:29 EDT 2013 # Grepping the whole error file for WARNING and the piping it to a grep for the date took about four minutes to complete on the gateway. This will only get longer and the file will only get bigger as time goes by. # Using tail to get the last 5000 lines, I get about three days of errors (2000 of them are from one day, though) # Getting 5000 lines, then searching them by WARNING and then DATE took 15 seconds on the gateway. yesterdayDate=$(./getYesterday) warningLogs=$(tail -5000 /mnt/sd/blah.txt | grep WARNING | grep "$yesterdayDate") sleep 30 { sleep 5 echo "ehlo blah.com" sleep 5 echo "auth plain blah" sleep 5 echo "mail from: blah@blah.com" sleep 5 echo "rcpt to: me@blah.com" sleep 5 echo "data" sleep 5 echo "Hi!" sleep 1 echo "Here are all the warnings and faults from yesterday:" sleep 1 echo "$yesterdayDate" sleep 1 echo "NOTE: All times are UTC." sleep 1 echo "" sleep 1 echo "$warningLogs" sleep 10 echo "" sleep 1 echo "Good luck," sleep 1 echo "The Robot" sleep 5 echo "." sleep 20 echo "quit" sleep 5 } | telnet blah.com port exit </code></pre> <p>I've tried using normal parentheses too before the pipe. I've read the man page for ash and am still doing something stupid. I suspect it's some kind of child process business going on.</p> <p>This works fine from bash, btw.</p> <p>Thanks in advance!</p> <hr> <p>Note -- I simplified the script to be just:</p> <pre><code>echo "quit" | telnet blah.com port </code></pre> <p>It does exactly what you'd expect in bash, but I see nothing happen in ash. Replacing the echo with "sleep 10" shows sleep running as a process, but not telnet.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload