07-25-2008
ssh script problem problem
Hi
Please help me with the following problem with my script.
The following block of code is not repeating in the while loop and exiting after searching for first message.
input_file
==========
host001-01
host001-02
2008-07-23 13:02:04,651 [DEBUG] [ageListenerThreadPool : 0] ConnectionFactory - Setting session state for connection.
2008-07-23 12:59:47,203 [DEBUG] [ageListenerThreadPool : 2] ConnectionFactory - Setting session state for connection.
host001-03
2008-07-24 11:51:56,883 [DEBUG] [AQUEDUCT-WebContainer : 1] ConnectionFactory - Setting session state for connection.
2008-07-24 11:47:18,448 [DEBUG] [ageListenerThreadPool : 2] ConnectionFactory - Setting session state for connection.
Shell script code
=================
while read line; do
temp_output=`echo $line | grep host001`
if [ "$temp_output" != "" ]; then
SERVER="$line"
else
thread_name=`echo $line | awk '{print $4,$5,$6}' | perl -wn -e 'print "$1\n" if m{[\[](.*?)[\]]};'`
date_string=`echo $line | awk '{print $1,$2}'`
ssh $SERVER cat "\`find / -mtime -1 -name 'app.log*' | sort -r\`" | fgrep -H -B25 '$date_string' | egrep -e 'The Message is' | egrep -e '$thread_name';
fi
done < $input_file
Expected Output:
===============
It should search for the strings on each host and display the message ( Please note that i have modified code to paste in the forum) and instead it's displaying output for first message(2008-07-23 13:02:04,651 [DEBUG]) and exiting the script and no error messages.
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi,
Just recently we seem to be getting the following error message relating to SSH when we run the UNIX script in background mode:
warning: You have no controlling tty. Cannot read confirmation.^M
warning: Authentication failed.^M
Disconnected; key exchange or algorithm negotiation... (1 Reply)
Discussion started by: budrito
1 Replies
2. UNIX for Dummies Questions & Answers
Hi Floks!
This is Sravan!
I am new to linux and I am trying to write bash shell script in which I want to change the user but the statements which are after the "su " command are not working that I mean I want to execute some statements as the changed user
here is the code
... (2 Replies)
Discussion started by: sravanp
2 Replies
3. AIX
I thought I had seen all errors in SSH but the following is new to me:
buffer_get: trying to get more bytes 129 than in buffer 6
Anyone seen this before please? Google search returns nothing of use that I can see.
I am running an lpar on a 52A and the O/S is AIX 5.3 TL 4CSP. (2 Replies)
Discussion started by: johnf
2 Replies
4. Solaris
Hi,
I am trying to ssh to a server.
Senario is as below:
I have two servers A and B both are solaris and having ssh version
Sun_SSH_1.1, SSH protocols 1.5/2.0, OpenSSL
I have created proper keys on both using key-gen and copied public keys appropriatly.
I am able to ssh from A to B... (1 Reply)
Discussion started by: Muktesh
1 Replies
5. Shell Programming and Scripting
I'm writing a script which is meant to ssh into a remote machine, sed a file there, and write the output to a new file on the remote machine. Obviously the easy way to do this is to write and execute the script on the remote machine, but I'm trying to do this all via ssh since I like to keep and... (4 Replies)
Discussion started by: maethlin
4 Replies
6. Shell Programming and Scripting
Hi,
I have 2 users say user a and user b both in different unix boxes.
I thave to execute a script in user b via user a.
I tried using ssh for it but my script is not getting executed.
My script goes as:
from user a-
ssh userb@host " sh script.sh"
script.sh is placed in user b... (11 Replies)
Discussion started by: Taranjeet Singh
11 Replies
7. Shell Programming and Scripting
Hi,
When runnin the following script it complte successfully with out any problem
#!/bin/sh
SERV="crm1"
for s in $SERV
do
export WebLogicSessions=`ssh psoft@$s "cd /software/psoft/scripts ; ./getweblogicsessions.sh crm1 8001 PIA | awk '{print $1}' `
echo "Checking number of... (0 Replies)
Discussion started by: yoavbe
0 Replies
8. UNIX for Dummies Questions & Answers
Hi i m writing a script which will fetch data from different machines and display it on single terminal.
I have created a file named SERVERNAMES containing ip address of machines i need to monitor.
Then for every IP i m issuing ssh command to get date on that machine.
However When i m trying... (3 Replies)
Discussion started by: pinga123
3 Replies
9. Solaris
Hi Guys,
when I try to login to one of my sun server (sparc) from within an open putty session on another server I get this message:
bash-3.2$ ssh 10.0.0.10
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @... (1 Reply)
Discussion started by: cjashu
1 Replies
10. Shell Programming and Scripting
I want to execute below the script for remote server.i am not able to execute below the script please help me urgent for this issue.i getting below the error
ssh user@server<<EOJ
cd path
for i in *
do
echo $i
done
EOJ
Pseudo-terminal will not be allocated because stdin is not a... (1 Reply)
Discussion started by: SAUD PASHA
1 Replies
LEARN ABOUT PHP
db2_autocommit
DB2_AUTOCOMMIT(3) 1 DB2_AUTOCOMMIT(3)
db2_autocommit - Returns or sets the AUTOCOMMIT state for a database connection
SYNOPSIS
mixed db2_autocommit (resource $connection, [bool $value])
DESCRIPTION
Sets or gets the AUTOCOMMIT behavior of the specified connection resource.
PARAMETERS
o $connection
- A valid database connection resource variable as returned from db2_connect(3) or db2_pconnect(3).
o $value
- One of the following constants:
o DB2_AUTOCOMMIT_OFF - Turns AUTOCOMMIT off.
o DB2_AUTOCOMMIT_ON - Turns AUTOCOMMIT on.
RETURN VALUES
When db2_autocommit(3) receives only the $connection parameter, it returns the current state of AUTOCOMMIT for the requested connection as
an integer value. A value of 0 indicates that AUTOCOMMIT is off, while a value of 1 indicates that AUTOCOMMIT is on.
When db2_autocommit(3) receives both the $connection parameter and $autocommit parameter, it attempts to set the AUTOCOMMIT state of the
requested connection to the corresponding state. Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
Retrieving the AUTOCOMMIT value for a connection
In the following example, a connection which has been created with AUTOCOMMIT turned off is tested with the db2_autocommit(3) func-
tion.
<?php
$options = array('autocommit' => DB2_AUTOCOMMIT_OFF);
$conn = db2_connect($database, $user, $password, $options);
$ac = db2_autocommit($conn);
if ($ac == 0) {
print "$ac -- AUTOCOMMIT is off.";
} else {
print "$ac -- AUTOCOMMIT is on.";
}
?>
The above example will output:
0 -- AUTOCOMMIT is off.
Example #2
Setting the AUTOCOMMIT value for a connection
In the following example, a connection which was initially created with AUTOCOMMIT turned off has its behavior changed to turn
AUTOCOMMIT on.
<?php
$options = array('autocommit' => DB2_AUTOCOMMIT_OFF);
$conn = db2_connect($database, $user, $password, $options);
// Turn AUTOCOMMIT on
$rc = db2_autocommit($conn, DB2_AUTOCOMMIT_ON);
if ($rc) {
print "Turning AUTOCOMMIT on succeeded.
";
}
// Check AUTOCOMMIT state
$ac = db2_autocommit($conn);
if ($ac == 0) {
print "$ac -- AUTOCOMMIT is off.";
} else {
print "$ac -- AUTOCOMMIT is on.";
}
?>
The above example will output:
Turning AUTOCOMMIT on succeeded.
1 -- AUTOCOMMIT is on.
SEE ALSO
db2_connect(3), db2_pconnect(3).
PHP Documentation Group DB2_AUTOCOMMIT(3)