From: J G Miller on 25 Apr 2010 09:23 Op Zondag, 25 April 2010 15:05:38 +0200, Houghi schreef: > I want to write output to a file via a script. The endresult must be: ls > | myscript You need to use ls -1 | read_listing where read_listing is the script #! /bin/sh while read file_name do echo "file name is ${file_name}" done exit 0
From: J G Miller on 25 Apr 2010 11:18 Op Zondag, 25 April 2010 15:52:00 +0200, Houghi schreef: > What if I do not use `ls` but e.g. `man hier` or `dig soa houghi.eu` as > command? What I want is the screen output to a file though a script. > The above does unfortunatly neither. Actually it does work just fine -- dig soa houghi.eu | read_ls file name is file name is ; <<>> DiG 9.6.1-P2 <<>> soa houghi.eu file name is ;; global options: +cmd file name is ;; Got answer: file name is ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33796 file name is ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 13, ADDITIONAL: 10 file name is file name is ;; QUESTION SECTION: file name is ;houghi.eu. IN SOA file name is file name is ;; ANSWER SECTION: file name is houghi.eu. 7189 IN SOA ns14.zoneedit.com. soacontact.zoneedit.com. 1144871189 14400 7200 950400 7200 file name is file name is ;; AUTHORITY SECTION: file name is . 257563 IN NS j.root-servers.net. file name is . 257563 IN NS i.root-servers.net. file name is . 257563 IN NS b.root-servers.net. file name is . 257563 IN NS k.root-servers.net. file name is . 257563 IN NS h.root-servers.net. file name is . 257563 IN NS c.root-servers.net. file name is . 257563 IN NS e.root-servers.net. file name is . 257563 IN NS m.root-servers.net. file name is . 257563 IN NS f.root-servers.net. file name is . 257563 IN NS a.root-servers.net. file name is . 257563 IN NS d.root-servers.net. file name is . 257563 IN NS l.root-servers.net. file name is . 257563 IN NS g.root-servers.net. file name is file name is ;; ADDITIONAL SECTION: file name is a.root-servers.net. 561608 IN A 198.41.0.4 file name is a.root-servers.net. 558275 IN AAAA 2001:503:ba3e::2:30 file name is b.root-servers.net. 561608 IN A 192.228.79.201 file name is c.root-servers.net. 561608 IN A 192.33.4.12 file name is d.root-servers.net. 561608 IN A 128.8.10.90 file name is e.root-servers.net. 561608 IN A 192.203.230.10 file name is f.root-servers.net. 561608 IN A 192.5.5.241 file name is f.root-servers.net. 561610 IN AAAA 2001:500:2f::f file name is g.root-servers.net. 561608 IN A 192.112.36.4 file name is h.root-servers.net. 561608 IN A 128.63.2.53 file name is file name is ;; Query time: 2 msec file name is ;; SERVER: 192.168.11.17#53(192.168.11.17) file name is ;; WHEN: Sun Apr 25 17:09:29 2010 file name is ;; MSG SIZE rcvd: 486 file name is Just remove "file name is" from the echo, and rename the variable file_name to something more appropriate like input_line. Please see <http://tldp.org/LDP/abs/html/internal.html#READPIPEREF> for more examples on piping into shell scripts.
|
Pages: 1 Prev: notify-send Next: 11.1: SaX2 forgets monitor size after config |