LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-25-2012, 03:33 AM   #1
Gabel__
LQ Newbie
 
Registered: Jul 2012
Posts: 1

Rep: Reputation: Disabled
Expect / BASH script


Hi, im trying to write an BASH / Expect script to do some config checks. But im having an issu whit the split function in one of my functions.

All that i think is need is posted under, everything seems to work perfekt untill the script gets to "THIS LINE". Where i get the following error:

--------------------
wrong # args: should be "read channelId ?numChars?" or "read ?-nonewline? channelId"
while executing
"read "
invoked from within
"split [read ] '\n'"
invoked from within
"set acc_list [split [read ] '\n']
"
--------

Code:
function telnet_set_acl130 (){
expect	<< EOF

	set timeout 20
	set promt "% "

	#Kobler til telnet til addr 
	spawn telnet $HOST

	expect "Username:"
	send "$USER\r"

	expect "Password:"
	send "$PASS\r"

	expect ">"
	send "en\r"

	expect "Password:"
	send "$en\r"

	#Fjerner acl130 fra vlan 90
	expect "#"
	send "conf t\r"

	expect "#"
	send "interface vlan $vlan\r"

	expect "#"
	send "no ip access-group 130 out\r"

	expect "#"
	send "end\r"

	#Fjerner acl130 fra noden
	expect "#"
	send "conf t\r"

	expect "#"
	send "no access-list 130\r"

	#Oppretter nye acl130 paa noden
	#Leser data fra "ok_acl/$rtacl" 
	set load_fh [open ok_acl/$rtacl r] 
	set acc_list [split [read $load_fh] '\n'] <<<--- THIS LINE
	close $load_fh

	foreach ip $acc_list {

		if {$ip != ""} {
			send "$ip\r"
		}
		expect "(config)#"
	}

	send "interface vlan $vlan\r"

	expect "#"
	send "ip access-group 130 out\r"

	expect "#"
	send "end\r"

	#Lagrer endringer
	expect "#"
	send "wr\r"

	expect "#"
	send "exit\r"
EOF
}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem running an Expect script within a Bash script mbeipi Programming 9 02-10-2018 05:00 AM
[SOLVED] Problem in exporting variable from bash script to expect script uk.engr Linux - Newbie 3 06-14-2012 01:57 AM
Expect with bash script edwardcode Programming 14 08-13-2011 08:06 AM
[SOLVED] /usr/bin/expect : Script to check server load using both expect and bash Soji Antony Programming 1 07-27-2010 11:27 PM
Embed expect in bash script prpednek Linux - General 3 05-15-2010 06:36 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration