How do I get retrieved info into a log? 
Author Message
 How do I get retrieved info into a log?

I am trying to gather information on some 700 unix boxes on my company
network.

The boxes are all either IBM or Sun and I am trying to get a list of
operation system levels.

I have two scripts that use expect to login to the boxes, one for IBM
and one for Sun. Once logged in the script should issue oslevel or uname
-r depending on which script I run.

How do I get the information returned from the command sent into a log?

I have set up a proc;

set oslevel_log "oslevel.log"

proc os_log {msg default} {
        global oslevel_log
        log_file $oslevel_log
        if {"$default" == ""} {
                        send_log "$msg\n"
                } else {
                        send_user "$msg\n"
                }
        log_file

Quote:
}

The section to read the oslevel which I know does not work is this;

set osresult ""
                  send "oslevel\r"
                  expect {
                          "(.*)\n" {
                          set osresult $expect_out(1,string)
                          os_log "OS Level of $hostname is $osresult"
                          }

In debug mode, I see the script logging in, sending the oslevel command
and saying;

expect: does "oslevel\r\n4.3.3.0\r\n" (spawn_id 6) match glob pattern
"(.*)\n"? no

So how do I get the info oslevel returned into the oslevel.log file?

Thanks in advance

Steve

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 16 Mar 2003 03:00:00 GMT  
 How do I get retrieved info into a log?
Please note that finishing and running this script is time limited and I
don't have time to go out and buy the manual. I have looked at many
examples but cannot find any of any use fro this sort of thing.

Steve

Sent via Deja.com http://www.deja.com/
Before you buy.



Sun, 16 Mar 2003 03:00:00 GMT  
 How do I get retrieved info into a log?
A step in the right direction;

I have a new proc;

set oslevel_log "oslevel.log"

proc os_log {msg} {
        global oslevel_log
        log_file $oslevel_log
        send_log "$msg\n"
        log_file
        exit

Quote:
}

and a new section that asks for oslevel info (big);

while {[gets $filename line] != -1} {
        set hostname [lindex $line 0]
        scan $hostname "%1s" one_char
        # Check the line is not blank or is a comment
        if {[llength $line] == 0 || $one_char == "#"} {
                continue
        }

        spawn ping -s $hostname 56 1
        set timeout 3
        expect {
                "0% packet loss" {
                        log_out "host $hostname is alive" ""
                }
                timeout {
                        log_error "Error: no answer from $hostname"
"user"
                        continue
                }
        }

        set pass_count 0

        foreach password $pass_list {
                set timeout 20
                set prompt "(%|#|>||sh|\\\$) $"
                incr pass_count

                log_out "telnet to $hostname using password $pass_count"
"user"

                spawn telnet $hostname
                expect "ogin"    { send "root\r" }
                expect "assword" { send $password\r }
                expect {
                        -re $prompt {
                                log_out "Logged into host $hostname" ""
                        }
                        "(assword|ogin)" {
                                log_error "Error: $hostname password
number $pass_count incorrect" "user"
                                continue
                        }
                }
                log_out "Asking for OSLEVEL of $hostname at [exec date]"
""
                set osresult ""
                send -- "oslevel\r"
                expect {
                        "4.*" {
                        set osresult $expect_out(0,string){
                        os_log "OS Level of $hostname is $osresult"
                                }
                        }
                }
                                continue
                                log_out "Script finished at [exec date]"
""
                        }
                }

The script now runs a bit. It will read the first entry in the list of
hosts provided. It writes out to the os_log file (oslevel.log) but ends
it with a "{" and stops. Debug mode is giving me no clues as to why the
script will only do the first line in the list of hosts provided.

Need to buy the book..need to buy the book..need to.........

Can anyone help?

Steve

Sent via Deja.com http://www.deja.com/
Before you buy.



Sun, 16 Mar 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help retrieving info from operating system

2. Retrieving file info with Rexx

3. Retrieve MVS system info in COBOL

4. help retrieving / storing info in dictionary or gadfly

5. Retrieving Info From Web W/ Python

6. Getting currently logged in user name in VisualWorks

7. Getting Winows NT logged on user from Visual Works

8. Getting a list of logged-in users

9. Transaction Logging and Rollback Errors - info only

10. Getting a program to inform you when it's done

11. Doing emacs bindings or getting modifiers

12. HttpDist - getting errors, What I'm doing wrong

 

 
Powered by phpBB® Forum Software