Sponsored Content
Top Forums Shell Programming and Scripting expect telnet script execute by cronjob Post 302575758 by cssanangeles on Tuesday 22nd of November 2011 07:26:19 PM
Old 11-22-2011
expect telnet script execute by cronjob

hi, please help, keep getting this bolded error and look it up and people say
its your environment variable though i tried to set it manually in expect..it run fine if i run it manually but once i run it by cronjob it error below..i tried to comment out ip/login info with *..

Code:
logfile::
START OF SCRIPT
****************************SERVER:**********************
*********************************************************
array set ::env {LS_COLORS {} LESSOPEN {|/usr/bin/lesspipe.sh %s} 
TERM xterm CVS_RSH ssh SHELL /bin/bash ORACLE_BASE /u01/app/oracle SHLVL 2 G_BROKEN_FILENAMES PATH /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/sbin/:/usr/sbin:/home/oracle/bin:/u01/app/oracle/product/11.2.0/dbhome_1/bin:/u01/app/oracle/product/11.2.0/dbhome_1/OPatch:. _ /home/oracle/scripts/msa_config.exp USER oracle}
spawn telnet *****
manage
!Trying ****...

Connected to *****.

Escape character is '^]'.

Login: login
Password: *******

HP StorageWorks ***
System Name: ***
System Location: 
Version: W441P28

# show vdisk 
Name Size     Free    Own Pref   RAID   Disks Spr Chk  Status Jobs      
Press any key to continue (Q to quit)


expect script:
set env(TERM) xterm
set env(PATH) /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/sbin/:/usr/sbin:/home/oracle/bin:/u01/app/oracle/product/11.2.0/dbhome_1/bin:/u01/app/oracle/product/11.2.0/dbhome_1/OPatch:.

####set below to repopulate the environment
unset -nocomplain ::env(SSH_AUTH_SOCK)   ;# This one is session-bound anyway
puts[list array set ::env [array get ::env]]

set prompt "#"
set timeout -1
spawn telnet [lindex $argv 0]
match_max 200000
send -- "login\r"
expect -exact "login\r"
send -- "*"
expect -exact "*"
send -- "*"
expect -exact "*"
send -- "*"
expect -exact "*"
send -- "*"
expect -exact "*"
send -- "*"
expect -exact "*"
send -- "*"
expect -exact "*"
send -- "*"
expect -exact "*"
send -- "\r"
expect "$prompt"
send -- "show vdisk \r"
send -- "exit \r"
expect eof

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to execute a program at expect script

what i need is that after passwordless enter another program should execute. I can succeed passwordless login but ı could not execute (./son) program. pls help me (6 Replies)
Discussion started by: fozay
6 Replies

2. Shell Programming and Scripting

Telnet Expect script question

Hi all, I have written a small expect script which should spawn a telnet session login and execute some commands. #!/usr/bin/expect -f spawn telnet $env(IP) match_max 100000 expect "login:" send -- "******\n" expect -exact "Password:" send -- "****\n" expect "%" Now I have got... (2 Replies)
Discussion started by: stinkefisch
2 Replies

3. Shell Programming and Scripting

Expect script to automate telnet session

Hi all, I am currently running a daemon which creates a virtual terminal for testing purposes. Essentially, if I were to interact with it manually, this is what I get. john@test1:~$telnet localhost 7777 Trying ::1... Connected to localhost. Escape character is '^]' mip6d> pl eth2... (6 Replies)
Discussion started by: abxccd
6 Replies

4. Shell Programming and Scripting

Execute Shell Script from CRONJOB

Hi Users, I am Newbie to linux and cron. I have a requirement to run a job at 8 AM every Sunday. I am using RHEL 5. Based on the hints through google search I created crontab and added entry to call the shell script which will in turn login to Oracle user and execute a pl/sql block. ... (1 Reply)
Discussion started by: reachravi70
1 Replies

5. Shell Programming and Scripting

EXPECT script for Telnet automation. Need your support.

Dear experts, please help me . I've found simple EXPECT scripts and all works fine. But I need more automation in error handling and sending list of commands/output logging from multiple remote hosts. I have 10 hosts, for example: host1 192.168.1.1 LOGIN1 PASSWORD1 ...... ... (2 Replies)
Discussion started by: starchen
2 Replies

6. Shell Programming and Scripting

Calling Expect Script - Telnet

Hi All, I have an Expect script which logs into Cisco switch, performs a show interface command. I want to read a file of ip addresses which will be passed to the expect script. The script to read the file works, the expect script works on it's own but when i call the 'expect' script from the... (12 Replies)
Discussion started by: trinak96
12 Replies

7. Shell Programming and Scripting

Expect script cronjob running but dying prematurely

I have an Ubuntu machine that I'd like to update automatically. I've written an expect script to run the aptitude package manager and update my packages. Essentially it does: aptitude update && aptitude upgrade while answering "yes" at the appropriate time. It works quite nicely when run... (4 Replies)
Discussion started by: CluelessPerson
4 Replies

8. Shell Programming and Scripting

Expect script to execute a script on a remote host

Hi, I am new to the expect scripting. I have this expect script as below : spawn ssh remote_server -l id set pass "12345" set opt "s" expect "Password:" {send "$pass\r" ; } expect "*ENTER*" {send "Enter\r"; exp_continue } expect "Please select option :" {send... (2 Replies)
Discussion started by: curt137
2 Replies

9. Red Hat

Execute expect script during firstboot

closed (1 Reply)
Discussion started by: AbhishekAgrawal
1 Replies

10. Shell Programming and Scripting

How to execute commands on remote server using expect script?

I need to copy python script file to around 100 servers using expect script. 1. Copy script to my user home first(/home/myhome) on each remote server 2. change permissions on copied file to 766. 3. sudo to appuser1 account on remote server. copy script file from my user home to /usr/bin/... (1 Reply)
Discussion started by: kchinnam
1 Replies
rc.config(4)						     Kernel Interfaces Manual						      rc.config(4)

NAME
rc.config, rc.config.d - files containing system configuration information SYNOPSIS
DESCRIPTION
The system configuration used at startup is contained in files within the directory The file sources all of the files within and and exports their contents to the environment. /etc/rc.config The file is a script that sources all of the scripts, and also sources To read the configuration definitions, only this file need be sourced. This file is sourced by whenever it is run, such as when the command is run to transition between run states. Each file that exists in is sourced, without regard to which startup scripts are to be executed. /etc/rc.config.d The configuration information is structured as a directory of files, rather than as a single file containing the same information. This allows developers to create and manage their own configuration files here, without the complications of shared ownership and access of a common file. /etc/rc.config.d/* Files This is where files containing configuration variable assignments are located. Configuration scripts must be written to be read by the POSIX shell, and not the Bourne shell, or In some cases, these files must also be read and possibly modified by control scripts or the sam program. See sd(4) and sam(1M). For this reason, each variable definition must appear on a separate line, with the syntax: No trailing comments may appear on a variable definition line. Comment statements must be on separate lines, with the comment character in column one. This example shows the required syntax for configuration files: Configuration variables may be declared as array parameters when describing multiple instances of the variable configuration. For example, a system may contain two network interfaces, each having a unique IP address and subnet mask (see ifconfig(1M)). An example of such a dec- laration is as follows: Note that there must be no requirements on the order of the files sourced. This means configuration files must not refer to variables defined in other configuration files, since there is no guarantee that the variable being referenced is currently defined. There is no protection against environment variable namespace collision in these configuration files. Programmers must take care to avoid such prob- lems. /etc/TIMEZONE The file contains the definition of the environment variable. This file is required by POSIX. It is sourced by at the same time the files are sourced. SEE ALSO
rc(1M). rc.config(4)
All times are GMT -4. The time now is 08:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy