0

I am trying to prepend a message to the output of rsstail, this is what I have right now:

rsstail -o -i 15 --initial 0 http://feeds.bbci.co.uk/news/world/europe/rss.xml | awk -v time=$( date +\[%H:%M:%S_%d/%m/%Y\] ) '{print time,$0}' | tee someFile.txt

which should give me the following:

[23:46:49_23/10/2014] Title: someTitle

After the command I have a | while read line do ... end which never gets called because the above command does not output a single thing. What am I doing wrong?

PS: I am using the python version of rsstail, since the other one kept on crashing (https://github.com/gvalkov/rsstail.py)

EDIT:

As requested in the comments the command:

rsstail -o -i 15 --initial 0 http://feeds.bbci.co.uk/news/world/europe/rss.xml

Will give back a message like the following when a new article is found

Title: Sweden calls off search for sub
ruben1691
  • 353
  • 3
  • 20
  • 1
    Can you please paste the sample output of rsstail -o -i 15 --initial 0 http://feeds.bbci.co.uk/news/world/europe/rss.xml. Dont expect people will know what rsstail is and what it does. – SMA Oct 24 '14 at 07:02
  • Your `awk` commands works fine for me. Your problem may lie elsewhere. – John1024 Oct 24 '14 at 07:10
  • @almasshaikh I have added the output you requested – ruben1691 Oct 24 '14 at 07:24
  • @John1024 Are you using the C version or the python version of rsstail? – ruben1691 Oct 24 '14 at 07:24
  • @user2287089 I checked _only_ the `awk` portion of the command: it worked as it was supposed to work. I didn't use `rsstail`. As per almas suggestion, I think it would help if you included a sample of the output of your `rsstail` command here. – John1024 Oct 24 '14 at 07:30
  • am not sure what your while loop does further but using awk it works for me echo "Title: Sweden calls off search for sub" | awk -v time=$( date +\[%H:%M:%S_%d/%m/%Y\] ) '{print time,$0}' | tee files.txt | awk '{print $0}' – SMA Oct 24 '14 at 07:31
  • I have added it, it's in the original post – ruben1691 Oct 24 '14 at 07:31
  • @user2287089 So, your `rsstail` command is working. The `awk` command works for both almas shaikh and me. That leads me to suspect the problem is in the `while` loop. – John1024 Oct 24 '14 at 07:35
  • @John1024 Funnily enough, rsstail works when alone, but when I substitute it to the echo command, the whole thing falls to pieces...looks like the chaining of the commands makes it fail. Right now the while loop is not a concern – ruben1691 Oct 24 '14 at 07:38
  • Perhaps the problem is output buffering in rsstail or elsewhere? For example, if you run `rsstail` directly in the terminal, it prints right away, right? What if you pipe that same command to `cat`? If it no longer prints right away, it's buffering. – John Zwinck Oct 24 '14 at 07:45
  • @JohnZwinck This is ridiculous...if I run `rsstail -o -i 15 --initial 0 http://feeds.bbci.co.uk/news/world/europe/rss.xml | cat | tee aFile.txt` it works...looks like there is an incompatibility between `awk` and `rsstail` – ruben1691 Oct 24 '14 at 07:48

1 Answers1

0

It seems that my rsstail is different from yours, but mine supports the option

-Z x    add heading 'x'

so that

rsstail -Z"$( date +\[%H:%M:%S_%d/%m/%Y\] ) " ...

does the job without awk; on the other hand, you do have some problem with buffering, is it possible to ask rsstail to stop after a given number of titles?

gboffi
  • 22,939
  • 8
  • 54
  • 85
  • You are right, I am using the Python version of rsstail, being as the other one kept on crashing. But if you say it works this way, I might as well give it a shot – ruben1691 Oct 24 '14 at 09:33
  • I have just stumbled upon http://unix.stackexchange.com/questions/25372/turn-off-buffering-in-pipe , have a look and see if this can get what you need, – gboffi Oct 24 '14 at 10:05
  • So this kind of solved my problem...I had to fix a couple of issues with my `apt-get` command, but I was able to install your same version of `rsstail`. By using the `-Z` option it works perfectly. Thanks! – ruben1691 Oct 27 '14 at 10:19