nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Expect and tcl - manymaint.exp script

This is a discussion on Expect and tcl - manymaint.exp script within the Shell scripting forums, part of the Development/Scripting category; Hello everyone, i've been searching for close to a week now on this issue with so far no luck. I'm ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 12-13-2006, 08:15 AM
Junior Member
User
 
Join Date: Dec 2006
Posts: 6
Rep Power: 0
Intelligen
Default Expect and tcl - manymaint.exp script

Hello everyone, i've been searching for close to a week now on this issue with so far no luck. I'm really at a dead end of where to go from here. This is my issue.

I have a fresh install of Fedora 6 with expect and tcl installed by doing the following:

yum install tcl
yum install expect

Code:
[root@intelligen Routerscript]# autoexpect manymaint.exp
autoexpect started, file is script.exp
couldn't execute "manymaint.exp": no such file or directory
    while executing
"spawn -noecho manymaint.exp"
    ("eval" body line 1)
    invoked from within
"eval spawn -noecho $argv"
    invoked from within
"if {[llength $argv]>0} {
        eval spawn -noecho $argv
        cmd "spawn $argv"
} else {
        spawn -noecho $env(SHELL)
        cmd "spawn \$env(SHELL)"
}"
    (file "/usr/bin/autoexpect" line 315)
So after a bit of reading it I thought maybe it needed to be ran with expect and this is what i get running with expect.

Code:
[root@intelligen Routerscript]# expect ./manymaint.exp
invalid .command .name "savescript="y""
    while execudting
"savescript="y""
    (file "./manymaint.exp" line 19)
I'm lost on what to do but i'm really thinking my tcl isn't correctly installed. Could anyone help me out? I'm in crunch time before end of year. Thank you!

(I would post the remaining question but the forum says I must have 5 posts before you can post URL's/Links but i'm not posting anything like that. Can a mod help me out?)
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-13-2006, 04:09 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Hello Intelligen,

Welcome to nixCraft forum!

The limit is placed because of spammers. If you are regular user, after 5 post you will able to post URLS.

You can paste your code between
Code:
[code]your code[/code]
I think both are installed correctly; try as follows:
Code:
chmod +x manymaint.exp
./manymaint.exp
Also paste output of following command
Code:
head -1 manymaint.exp
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #3 (permalink)  
Old 12-13-2006, 07:25 PM
Junior Member
User
 
Join Date: Dec 2006
Posts: 6
Rep Power: 0
Intelligen
Default

I chmod the script yesterday and i believe i have correct rights on it now:

Code:
-rwxr-xr-x 1 root root    8672 Dec 12 20:38 manymaint.exp
I will PM you the location i got the script

Here is the output

Code:
[root@intelligen Routerscript]# head -1 ./manymaint.exp
#!/bin/sh
Reply With Quote
  #4 (permalink)  
Old 12-13-2006, 07:51 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

This is => http://expect.nist.gov/scripts/manymaint shell script and not expect script. Following output Line clearly indicates that this is a shell script:
Code:
#!/bin/sh
How do you run shell script?
Code:
chmod +x manymaint
./manymaint
To identify script use file command
Code:
file manymaint
What os and are you using? What you are trying to do? Router script??? Give me details so I can may point out more info
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #5 (permalink)  
Old 12-13-2006, 09:02 PM
Junior Member
User
 
Join Date: Dec 2006
Posts: 6
Rep Power: 0
Intelligen
Default

I apologize, my linux knowledge is very low. More of a windows administrator.

I am using Fedora 6. I tried to type out what i was doing in first post but it kept saying i needed 5 posts or more. Weird! What i'm trying to do change 300 router SNMP private and public strings.

We used the manymaint script before which generates a script.exp script.
So when i download manymaint its a .txt, what SHOULD i be renaming it too?
Reply With Quote
  #6 (permalink)  
Old 12-14-2006, 02:06 AM
Junior Member
User
 
Join Date: Dec 2006
Posts: 6
Rep Power: 0
Intelligen
Default

I've did the chmod and rights look as follows:
Code:
-rwxr-xr-x 1 root root    8672 Dec 12 20:38 manymaint
When i run the script with the following:

Code:
[root@intelligen Routerscript]# ./manymaint
I get the following...

Code:
[root@intelligen Routerscript]# ./manymaint
bash: ./manymaint: /bin/sh^M: bad interpreter: No such file or directory
Reply With Quote
  #7 (permalink)  
Old 12-14-2006, 06:18 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Create a sym link and try again
Code:
ln -s /bin/bash /bin/sh
I understand your windows background but keep working and one day you will master Linux

Cheers
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #8 (permalink)  
Old 12-14-2006, 07:23 PM
Junior Member
User
 
Join Date: Dec 2006
Posts: 6
Rep Power: 0
Intelligen
Default

Yup, i just need to keep with it. I need to install it as my main OS to force me to figure things out.

Ok when creating the symbolic link i get this:

Code:
[root@intelligen Routerscript]# ln -s /bin/bash /bin/sh
ln: creating symbolic link `/bin/sh' to `/bin/bash': File exists
Quote:
Originally Posted by nixcraft
Create a sym link and try again :)
Code:
ln -s /bin/bash /bin/sh
I understand your windows background but keep working and one day you will master Linux

Cheers
Reply With Quote
  #9 (permalink)  
Old 12-14-2006, 07:45 PM
Junior Member
User
 
Join Date: Dec 2006
Posts: 6
Rep Power: 0
Intelligen
Default

I think i figured it out. Since i had edited in notepad on a windows system the file was reading incorrectly as found when i searched on google.

This is what it said:

Quote:
DOS: CRLF both. Which is why if you do "cat -v" on a DOS file you'll see a "^M" (control m is carriage return) at the end of each line. And that is why scripts don't work when written with Microsoft Notepad. The kernel looks for "/bin/sh^M" which doesn't exist. There's a "/bin/sh", but nothing with a "^M" appended.
So i then did a the following

Code:
vim
set ff=unix
That took care of problem and script ran great!

[/quote]
Reply With Quote
  #10 (permalink)  
Old 12-16-2006, 07:46 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Glad to know your problem is sorted out!
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
expect about helps pls samuel Shell scripting 0 03-05-2008 01:05 PM
interacting with expect monteo7 Shell scripting 1 03-04-2008 05:42 PM


All times are GMT +5.5. The time now is 06:23 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36