Page 1 of 1
a script to execute some commands?
Posted: Wed Nov 29, 2006 9:53 pm
by Gaougalos
I need a script to execute the followed commands:
-system telnet 0.0.0.1
(after that i must type a password)
-[my pass]
I want to do this automatically with a script
Can a script do this?
Sorry for my English
Posted: Thu Nov 30, 2006 7:30 am
by mneumark
Posted: Thu Nov 30, 2006 9:11 am
by Gaougalos
Sorry my friend, but how i can import the pass?
For the first one i must write in the script:
/system telnet 0.0.0.1
Then, how it takes the pass?
:put 8975 (this is my password)
sorry but i' m a little bit ignorant
Posted: Thu Nov 30, 2006 9:18 am
by mneumark
I'm not exactly sure on that one but here is what i would try...
:put "password" \r
Posted: Thu Nov 30, 2006 2:39 pm
by Gaougalos
Thank u very much.
It works when i write:
/system telnet 0.0.0.1
:put "8975"
Now i need to continue the script.
The next command i want to typed after that is :
/enable
(and after that again pass)
:put "5552"
But this is not working.
Witch is the correct formulation?
Posted: Thu Nov 30, 2006 11:52 pm
by Gaougalos
Please, help me, i need this script...
Posted: Fri Dec 01, 2006 8:50 am
by normis
another password after connecting to the machine? two passwords? is this other machine a RouterOS?
Posted: Fri Dec 01, 2006 10:00 am
by mneumark
When you are sending a /enable command using a script to a different box you are going to want to do :put "/enable"
Posted: Fri Dec 01, 2006 4:54 pm
by Gaougalos
When you are sending a /enable command using a script to a different box you are going to want to do :put "/enable"
Man, thank u very much.
Here it is:
/system telnet 0.0.0.1
:put "8975"
:put "/enable"
(and now i want to give another pass so i write)
:put {:put "5552"}
:put "/clear"
The last 2 lines are not working.
The script is running but it doesn't do what i want,
so i suppose that something in the 2 last lines is not correct
Posted: Sat Dec 02, 2006 1:27 am
by Gaougalos
I would try to make it more comprehensible.
In a new terminal on a mikrotik i write these commands:
-system telnet 0.0.0.1
-(after i write this, i must type a password so the pass o type is: )8975
-enable
-(after enable i must type again pass which is: )5552
-clear ip
So i write with your help this script to do this job:
/system telnet 0.0.0.1
:put "8975"
:put "/enable"
:put ":put "5552" "
:put ":put "/clear ip" "
But it's not working.
Where is the error?
Does anybody knows how to write this script correct?
Posted: Sat Dec 02, 2006 1:28 am
by Gaougalos
Sorry, double post
And sorry for my English. I'm not very good at it
Posted: Sat Dec 02, 2006 2:46 am
by changeip
I don't think you will get far trying to script a telnet session from MT to another box... never tried myself, but I doubt the :put works that way.
Posted: Sat Dec 02, 2006 8:45 am
by mneumark
Have you tried?
/system telnet 0.0.0.1
:put "8975"
:put "/enable"
:put "5552"
:put "/clear ip"
Posted: Sat Dec 02, 2006 11:39 am
by Gaougalos
No my friend
The problem is with the 2 last lines.
Without them the scrip is running
How we can put the second password????
Posted: Sat Dec 02, 2006 9:59 pm
by mneumark
/system telnet 0.0.0.1
:put "8975"
:put "/enable"
:put ":put 5552"
:put ":put /clear ip"
How about?
Posted: Sat Dec 02, 2006 11:11 pm
by Gaougalos
No
It is not working
Posted: Mon Dec 04, 2006 9:56 am
by raivis-v
/system telnet 0.0.0.1
:put "8975"
:put "/enable"
:put ":put 5552"
:put ":put /clear ip"
How about?
Your script ends at this line
/system telnet 0.0.0.1
And that is it. It stops here. /system telnet ... is a command, that has already ended when you do :put "8975". I do not understand, how do you determine that problems is with last two lines. Problem is already in first two lines. You can not put or print anything in /system script.
I suggest you tu use TCL or EXPECT scripts. They are ment for that.
Posted: Mon Dec 04, 2006 10:28 am
by normis
yes exactly, you cannot make a script connect to another router and issue commands on that side.
Posted: Thu Dec 07, 2006 1:09 am
by Gaougalos
Does anybody knows who i can make a script which can run these commands?
Can anybody write this to me?
I'll be very grateful.
I don't know where is exactly the problem but i need it.
So if someone knows how to make this script running, he helps me a lot
Posted: Thu Dec 07, 2006 7:36 am
by raivis-v
If you have linux OS, expect should be in repositories. You just need to install it. If you run MS Windows OS, try to look here:
http://expect.nist.gov/ There are also examples how to do this trick.