- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- I need help making this work... getnodeinfo: synta...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 01:14 AM
02-03-2005 01:14 AM
Here's the error message when I try to execute the dolist script.
$ ./dolist
/export/home/rjohnson/expectstuff/getnodeinfo: syntax error at line 26: `}' unexpected
/export/home/rjohnson/expectstuff/getnodeinfo: syntax error at line 26: `}' unexpected
/export/home/rjohnson/expectstuff/getnodeinfo: syntax error at line 26: `}' unexpected
$
The scripts are shown below.
$ pwd
/export/home/rjohnson/expectstuff
$ ls
dolist getnodeinfo list script.original
$ more dolist
#!/bin/sh
for device in `cat /export/home/rjohnson/expectstuff/list`
do
/export/home/rjohnson/expectstuff/getnodeinfo $device
done
$ more list
10.21.21.13
10.21.21.11
10.21.253.11
$ more getnodeinfo
set username "ciscoworks"
set password "thepasswordforciscoworks"
while { $n < 5 } {
spawn "/bin/sh"
send "telnet $HOSTNAME\r"
sleep 1
expect "Username:"
send "$username\r"
expect "Password"
send "$password\r"
send "\r\r"
"Welcome" {
incr pass0
set n 5
set p 0
close
}
"from" {
send "id\r"
expect {
$username {
incr pass0
set n 5
close
}
}
}
"login: $" {
set pass1 0
puts stdout "Expect return: $expect_out(0,string)"
puts stdout "Failed login"
send "\x1d\x0d"
expect "telnet"
send "close\r"
send "quit\r"
close
}
}
incr n
}
$
Solved! Go to Solution.
- Tags:
- expect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 01:20 AM
02-03-2005 01:20 AM
Re: I need help making this work... getnodeinfo: syntax err
at least the getnodeinfo seems to be missing an expect directive. Either use "expect getnodedinfo" or put "#!/yourpath/expect" as first line of the getnodeinfo script.
regards,
Thierry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 01:29 AM
02-03-2005 01:29 AM
Re: I need help making this work... getnodeinfo: syntax err
$ head -2 getnodeinfo
#!/opt/sfw/bin/expect
set username "ciscoworks"
$ ./dolist
can't read "n": no such variable
while executing
"while { $n < 5 } {
spawn "/bin/sh"
send "telnet $HOSTNAME\r"
sleep 1
expect "Username:"
send "$username\r"
expect "Password"
send "$password\r"
send "..."
(file "/export/home/rjohnson/expectstuff/getnodeinfo" line 4)
can't read "n": no such variable
while executing
"while { $n < 5 } {
spawn "/bin/sh"
send "telnet $HOSTNAME\r"
sleep 1
expect "Username:"
send "$username\r"
expect "Password"
send "$password\r"
send "..."
(file "/export/home/rjohnson/expectstuff/getnodeinfo" line 4)
can't read "n": no such variable
while executing
"while { $n < 5 } {
spawn "/bin/sh"
send "telnet $HOSTNAME\r"
sleep 1
expect "Username:"
send "$username\r"
expect "Password"
send "$password\r"
send "..."
(file "/export/home/rjohnson/expectstuff/getnodeinfo" line 4)
$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 03:04 AM
02-03-2005 03:04 AM
Re: I need help making this work... getnodeinfo: syntax err
set n 0
while { $n < 5 } {
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 03:29 AM
02-03-2005 03:29 AM
Re: I need help making this work... getnodeinfo: syntax err
set HOSTNAME [lindex $argv 0]
Regards,
Sergejs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 04:51 AM
02-03-2005 04:51 AM
Re: I need help making this work... getnodeinfo: syntax err
I did set the value for n and that error message is taken care of.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 05:16 AM
02-03-2005 05:16 AM
Re: I need help making this work... getnodeinfo: syntax err
set HOSTNAME [lindex $argv 0]
Here's what I'm getting now.
$ ./dolist
spawn /bin/sh
telnet 10.21.21.13
$ Trying 10.21.21.13...
Connected to 10.21.21.13.
Escape character is '^]'.
***********************************************************
Unauthorized use of DC Government computing systems may
involve not only transgression of DC Government policy,
but also a violation of state and federal laws.
Unauthorized use is a crime and may involve criminal and
civil penalties. Violators will be prosecuted to the full
extent of the law.
Here's the getnodeinfo script
*********************************************
#!/opt/sfw/bin/expect
set username "ciscoworks"
set password "just4us"
set HOSTNAME [lindex $argv 0]
set n 0
while { $n < 5 } {
spawn "/bin/sh"
send "telnet $HOSTNAME\r"
sleep 1
expect "Username:"
send "$username\r"
expect "Password"
send "$password\r"
send "\r\r"
"Welcome" {
incr pass0
set n 5
set p 0
close
}
"from" {
send "id\r"
expect {
$username {
incr pass0
set n 5
close
}
}
"login: $" {
set pass1 0
puts stdout "Expect return: $expect_out(0,string)"
puts stdout "Failed login"
send "\x1d\x0d"
expect "telnet"
send "close\r"
send "quit\r"
close
}
}
incr n
}
Keyboard inputs are monitored in the event of a real or
perceived security incident. Logon constitutes agreement
to monitoring of activities.
************************************************************
User Access Verification
Username: ciscoworks
Password: invalid command name "Welcome"
while executing
""Welcome" {
incr pass0
set n 5
set p 0
close
}"
("while" body line 10)
invoked from within
"while { $n < 5 } {
spawn "/bin/sh"
send "telnet $HOSTNAME\r"
sleep 1
expect "Username:"
send "$username\r"
expect "Password"
send "$password\r"
send "..."
(file "/export/home/rjohnson/expectstuff/getnodeinfo" line 6)
spawn /bin/sh
telnet 10.21.21.11
$ Trying 10.21.21.11...
Connected to 10.21.21.11.
Escape character is '^]'.
***********************************************************
Unauthorized use of DC Government computing systems may
involve not only transgression of DC Government policy,
but also a violation of state and federal laws.
Unauthorized use is a crime and may involve criminal and
civil penalties. Violators will be prosecuted to the full
extent of the law.
Keyboard inputs are monitored in the event of a real or
perceived security incident. Logon constitutes agreement
to monitoring of activities.
************************************************************
User Access Verification
Username: ciscoworks
Password: invalid command name "Welcome"
while executing
""Welcome" {
incr pass0
set n 5
set p 0
close
}"
("while" body line 10)
invoked from within
"while { $n < 5 } {
spawn "/bin/sh"
send "telnet $HOSTNAME\r"
sleep 1
expect "Username:"
send "$username\r"
expect "Password"
send "$password\r"
send "..."
(file "/export/home/rjohnson/expectstuff/getnodeinfo" line 6)
spawn /bin/sh
telnet 10.21.253.11
$ Trying 10.21.253.11...
Connected to 10.21.253.11.
Escape character is '^]'.
***********************************************************
Unauthorized use of DC Government computing systems may
involve not only transgression of DC Government policy,
but also a violation of state and federal laws.
Unauthorized use is a crime and may involve criminal and
civil penalties. Violators will be prosecuted to the full
extent of the law.
Keyboard inputs are monitored in the event of a real or
perceived security incident. Logon constitutes agreement
to monitoring of activities.
************************************************************
User Access Verification
Username: ciscoworks
Password: invalid command name "Welcome"
while executing
""Welcome" {
incr pass0
set n 5
set p 0
close
}"
("while" body line 10)
invoked from within
"while { $n < 5 } {
spawn "/bin/sh"
send "telnet $HOSTNAME\r"
sleep 1
expect "Username:"
send "$username\r"
expect "Password"
send "$password\r"
send "..."
(file "/export/home/rjohnson/expectstuff/getnodeinfo" line 6)
$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 05:19 AM
02-03-2005 05:19 AM
Re: I need help making this work... getnodeinfo: syntax err
"while { $n < 5 } {
spawn "/bin/sh"
send "telnet $HOSTNAME\r"
you'll need to do this before the while loop.
if you do as has been suggested:
set HOSTNAME [lindex $argv 0]
this will set HOSTNAME to the first value passed on the command line, i.e. whatever $device has been set to (10.21.21.13, etc.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 05:32 AM
02-03-2005 05:32 AM
Re: I need help making this work... getnodeinfo: syntax err
Here's what I'm getting when I run the dolist script.
********************************************
$ ./dolist
spawn /bin/sh
telnet 10.21.21.13
$ Trying 10.21.21.13...
Connected to 10.21.21.13.
Escape character is '^]'.
***********************************************************
Unauthorized use of DC Government computing systems may
involve not only transgression of DC Government policy,
but also a violation of state and federal laws.
Unauthorized use is a crime and may involve criminal and
civil penalties. Violators will be prosecuted to the full
extent of the law.
Keyboard inputs are monitored in the event of a real or
perceived security incident. Logon constitutes agreement
to monitoring of activities.
************************************************************
User Access Verification
Username: ciscoworks
Password: invalid command name "Welcome"
while executing
""Welcome" {
incr pass0
set n 5
set p 0
close
}"
("while" body line 10)
invoked from within
"while { $n < 5 } {
spawn "/bin/sh"
send "telnet $HOSTNAME\r"
sleep 1
expect "Username:"
send "$username\r"
expect "Password"
send "$password\r"
send "..."
(file "/export/home/rjohnson/expectstuff/getnodeinfo" line 6)
spawn /bin/sh
$ telnet 10.21.21.11
Trying 10.21.21.11...
Connected to 10.21.21.11.
Escape character is '^]'.
***********************************************************
Unauthorized use of DC Government computing systems may
involve not only transgression of DC Government policy,
but also a violation of state and federal laws.
Unauthorized use is a crime and may involve criminal and
civil penalties. Violators will be prosecuted to the full
extent of the law.
Keyboard inputs are monitored in the event of a real or
perceived security incident. Logon constitutes agreement
to monitoring of activities.
************************************************************
User Access Verification
Username: ciscoworks
Password: invalid command name "Welcome"
while executing
""Welcome" {
incr pass0
set n 5
set p 0
close
}"
("while" body line 10)
invoked from within
"while { $n < 5 } {
spawn "/bin/sh"
send "telnet $HOSTNAME\r"
sleep 1
expect "Username:"
send "$username\r"
expect "Password"
send "$password\r"
send "..."
(file "/export/home/rjohnson/expectstuff/getnodeinfo" line 6)
spawn /bin/sh
$ telnet 10.21.253.11
Trying 10.21.253.11...
Connected to 10.21.253.11.
Escape character is '^]'.
***********************************************************
Unauthorized use of DC Government computing systems may
involve not only transgression of DC Government policy,
but also a violation of state and federal laws.
Unauthorized use is a crime and may involve criminal and
civil penalties. Violators will be prosecuted to the full
extent of the law.
Keyboard inputs are monitored in the event of a real or
perceived security incident. Logon constitutes agreement
to monitoring of activities.
************************************************************
User Access Verification
Username: ciscoworks
Password: invalid command name "Welcome"
while executing
""Welcome" {
incr pass0
set n 5
set p 0
close
}"
("while" body line 10)
invoked from within
"while { $n < 5 } {
spawn "/bin/sh"
send "telnet $HOSTNAME\r"
sleep 1
expect "Username:"
send "$username\r"
expect "Password"
send "$password\r"
send "..."
(file "/export/home/rjohnson/expectstuff/getnodeinfo" line 6)
$
Here's the getnodeinfo script
*********************************************
$ more getnodeinfo
#!/opt/sfw/bin/expect
set username "ciscoworks"
set password "just4us"
set HOSTNAME [lindex $argv 0]
set n 0
while { $n < 5 } {
spawn "/bin/sh"
send "telnet $HOSTNAME\r"
sleep 1
expect "Username:"
send "$username\r"
expect "Password"
send "$password\r"
send "\r\r"
"Welcome" {
incr pass0
set n 5
set p 0
close
}
"from" {
send "id\r"
expect {
$username {
incr pass0
set n 5
close
}
}
"login: $" {
set pass1 0
puts stdout "Expect return: $expect_out(0,string)"
puts stdout "Failed login"
send "\x1d\x0d"
expect "telnet"
send "close\r"
send "quit\r"
close
}
}
incr n
}
$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 05:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 05:59 AM
02-03-2005 05:59 AM
Re: I need help making this work... getnodeinfo: syntax err
Thanks so much for the help. I so much wish I was programmed to be a programmer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 06:02 AM
02-03-2005 06:02 AM
Re: I need help making this work... getnodeinfo: syntax err
Thanks so much.