problem with tail -f that need to add to each line constant string at the beginning of each line

2011-10-29 Thread dan12341234

Hi All

im running 4 scripts that perform ssh and tail -f on a file exist on 4
servers and display on the screen.
(1 script per servers)

ssh server1 tail -f /var/log/apache/access_log
ssh server2 tail -f /var/log/apache/access_log
ssh server3 tail -f /var/log/apache/access_log
ssh server4 tail -f /var/log/apache/access_log

the problem is that the display dosent show any identification from which
server each line

what i need is something with an echo servername, before each line printed
to the screen

Thanks A Lot
Dan

-- 
View this message in context: 
http://old.nabble.com/problem-with-tail--f-that-need-to-add-to-each-line-constant-string-at-the-beginning-of-each-line-tp32742979p32742979.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.




Re: problem with tail -f that need to add to each line constant string at the beginning of each line

2011-10-29 Thread Bob Proulx
dan12341234 wrote:
> im running 4 scripts that perform ssh and tail -f on a file exist on 4
> servers and display on the screen.
> (1 script per servers)
> 
> ssh server1 tail -f /var/log/apache/access_log
> ssh server2 tail -f /var/log/apache/access_log
> ssh server3 tail -f /var/log/apache/access_log
> ssh server4 tail -f /var/log/apache/access_log
> 
> the problem is that the display dosent show any identification from which
> server each line
> 
> what i need is something with an echo servername, before each line printed
> to the screen

There are many specialized programs to do exactly what you are asking
such as dsh (distributed shell) and other tools.  You might want to
investigate those.

But you can do what you want by using sed to prepend to the line.

  ssh -n server1 'tail -f /var/log/syslog | sed --unbuffered "s/^/$(hostname): 
/"'
  ssh -n server2 'tail -f /var/log/syslog | sed --unbuffered "s/^/$(hostname): 
/"'

You might consider applying the commands as standard input instead.  I
think it is easier to avoid quoting problems that way.

  echo 'tail -f /var/log/syslog | sed --unbuffered "s/^/$(hostname): /"' | ssh 
-T server1

Bob



Re: problem with tail -f that need to add to each line constant string at the beginning of each line

2011-10-29 Thread dan12341234

Thanks Bob

this solution is great.

Dan  


Bob Proulx wrote:
> 
> dan12341234 wrote:
>> im running 4 scripts that perform ssh and tail -f on a file exist on 4
>> servers and display on the screen.
>> (1 script per servers)
>> 
>> ssh server1 tail -f /var/log/apache/access_log
>> ssh server2 tail -f /var/log/apache/access_log
>> ssh server3 tail -f /var/log/apache/access_log
>> ssh server4 tail -f /var/log/apache/access_log
>> 
>> the problem is that the display dosent show any identification from which
>> server each line
>> 
>> what i need is something with an echo servername, before each line
>> printed
>> to the screen
> 
> There are many specialized programs to do exactly what you are asking
> such as dsh (distributed shell) and other tools.  You might want to
> investigate those.
> 
> But you can do what you want by using sed to prepend to the line.
> 
>   ssh -n server1 'tail -f /var/log/syslog | sed --unbuffered
> "s/^/$(hostname): /"'
>   ssh -n server2 'tail -f /var/log/syslog | sed --unbuffered
> "s/^/$(hostname): /"'
> 
> You might consider applying the commands as standard input instead.  I
> think it is easier to avoid quoting problems that way.
> 
>   echo 'tail -f /var/log/syslog | sed --unbuffered "s/^/$(hostname): /"' |
> ssh -T server1
> 
> Bob
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/problem-with-tail--f-that-need-to-add-to-each-line-constant-string-at-the-beginning-of-each-line-tp32742979p32745047.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.




bash cgi script dosent works from the browser

2011-10-29 Thread dan12341234


im writing a bash cgi on a new installed suse 11
Apache is working fine becouse when i click the ip on the internet browser i
get it It works!

i have these 3 questions:
1 when im trying to load the page http://server1/hello.cgi it doas not
opened, instead it is saved as a file.
cat hello.cgi
#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "Bash as CGI"
echo ""
echo "Hello world"
echo "Today is $(date)"
echo ""

2 html page opened as http://server1/mypage1.html only and not as
http://server1/mypage1 , is it possible to change it
3 is there a way to create STD output on the cgi web page like listbox or
textbox so command results will displayed there in a real time,
Commands like tail -f /var/log/apache/access_log  

Thanks in advance and any suggestion is welcome and appreciated

Dan
-- 
View this message in context: 
http://old.nabble.com/bash-cgi-script-dosent-works-from-the-browser-tp32745166p32745166.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.




Re: [bug] Command substitutions within C-style for loops. Semicolon causes error.

2011-10-29 Thread Chet Ramey
On 10/29/11 1:21 AM, Dan Douglas wrote:
> It seems the Bash parser can't distinguish between the semicolon as a
> command separator list operator, and the arithmetic context delimiter of
> the C-style for loop. I realize this construct isn't particularly useful.
> ksh93 and zsh handle it as expected, but in Bash it causes a syntax error
> on my system.

Thanks for the report.  The code that creates the three parts of the
arithmetic for loop is pretty naive; I'm not surprised that it doesn't
handle this right.  It will be fixed in the next release of bash.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/