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
getusershell(3C)					   Standard C Library Functions 					  getusershell(3C)

NAME
getusershell, setusershell, endusershell - get legal user shells SYNOPSIS
#include <unistd.h> char *getusershell(void); void setusershell(void); void endusershell(void); DESCRIPTION
The getusershell() function returns a pointer to a legal user shell as defined by the system manager in the file /etc/shells. If /etc/shells does not exist, the following locations of the standard system shells are used in its place: /bin/bash /bin/csh /bin/jsh /bin/ksh /bin/ksh93 /bin/pfcsh /bin/pfksh /bin/pfsh /bin/sh /bin/tcsh /bin/zsh /sbin/jsh /sbin/pfsh /sbin/sh /usr/bin/bash /usr/bin/csh /usr/bin/jsh /usr/bin/ksh /usr/bin/ksh93 /usr/bin/pfcsh /usr/bin/pfksh /usr/bin/pfsh /usr/bin/sh /usr/bin/tcsh /usr/bin/zsh /usr/sfw/bin/zsh /usr/xpg4/bin/sh The getusershell() function opens the file /etc/shells, if it exists, and returns the next entry in the list of shells. The setusershell() function rewinds the file or the list. The endusershell() function closes the file, frees any memory used by getusershell() and setusershell(), and rewinds the file /etc/shells. RETURN VALUES
The getusershell() function returns a null pointer on EOF. BUGS
All information is contained in memory that may be freed with a call to endusershell(), so it must be copied if it is to be saved. NOTES
Restricted shells should not be listed in /etc/shells. SunOS 5.11 1 Nov 2007 getusershell(3C)
All times are GMT -4. The time now is 10:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy