Community discussions

MikroTik App
 
User avatar
Gaougalos
just joined
Topic Author
Posts: 12
Joined: Tue Oct 31, 2006 7:31 pm

a script to execute some commands?

Wed Nov 29, 2006 9:53 pm

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
 
User avatar
mneumark
Member
Member
Posts: 370
Joined: Thu Jun 08, 2006 7:20 am
Location: Escalon, CA
Contact:

Thu Nov 30, 2006 7:30 am

Yes a script can do this.

http://www.mikrotik.com/docs/ros/2.9/system/scripting

Look for delay-time.
 
User avatar
Gaougalos
just joined
Topic Author
Posts: 12
Joined: Tue Oct 31, 2006 7:31 pm

Thu Nov 30, 2006 9:11 am

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
 
User avatar
mneumark
Member
Member
Posts: 370
Joined: Thu Jun 08, 2006 7:20 am
Location: Escalon, CA
Contact:

Thu Nov 30, 2006 9:18 am

I'm not exactly sure on that one but here is what i would try...

:put "password" \r
 
User avatar
Gaougalos
just joined
Topic Author
Posts: 12
Joined: Tue Oct 31, 2006 7:31 pm

Thu Nov 30, 2006 2:39 pm

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?
 
User avatar
Gaougalos
just joined
Topic Author
Posts: 12
Joined: Tue Oct 31, 2006 7:31 pm

Thu Nov 30, 2006 11:52 pm

Please, help me, i need this script...
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26964
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia
Contact:

Fri Dec 01, 2006 8:50 am

another password after connecting to the machine? two passwords? is this other machine a RouterOS?
 
User avatar
mneumark
Member
Member
Posts: 370
Joined: Thu Jun 08, 2006 7:20 am
Location: Escalon, CA
Contact:

Fri Dec 01, 2006 10:00 am

When you are sending a /enable command using a script to a different box you are going to want to do :put "/enable"
 
User avatar
Gaougalos
just joined
Topic Author
Posts: 12
Joined: Tue Oct 31, 2006 7:31 pm

Fri Dec 01, 2006 4:54 pm

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
 
User avatar
Gaougalos
just joined
Topic Author
Posts: 12
Joined: Tue Oct 31, 2006 7:31 pm

Sat Dec 02, 2006 1:27 am

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?
Last edited by Gaougalos on Sat Dec 02, 2006 1:30 am, edited 1 time in total.
 
User avatar
Gaougalos
just joined
Topic Author
Posts: 12
Joined: Tue Oct 31, 2006 7:31 pm

Sat Dec 02, 2006 1:28 am

Sorry, double post


And sorry for my English. I'm not very good at it
 
changeip
Forum Guru
Forum Guru
Posts: 3833
Joined: Fri May 28, 2004 5:22 pm

Sat Dec 02, 2006 2:46 am

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.
 
User avatar
mneumark
Member
Member
Posts: 370
Joined: Thu Jun 08, 2006 7:20 am
Location: Escalon, CA
Contact:

Sat Dec 02, 2006 8:45 am

Have you tried?

/system telnet 0.0.0.1
:put "8975"
:put "/enable"
:put "5552"
:put "/clear ip"
 
User avatar
Gaougalos
just joined
Topic Author
Posts: 12
Joined: Tue Oct 31, 2006 7:31 pm

Sat Dec 02, 2006 11:39 am

No my friend :cry:
The problem is with the 2 last lines.
Without them the scrip is running
How we can put the second password????
 
User avatar
mneumark
Member
Member
Posts: 370
Joined: Thu Jun 08, 2006 7:20 am
Location: Escalon, CA
Contact:

Sat Dec 02, 2006 9:59 pm

/system telnet 0.0.0.1
:put "8975"
:put "/enable"
:put ":put 5552"
:put ":put /clear ip"

How about?
 
User avatar
Gaougalos
just joined
Topic Author
Posts: 12
Joined: Tue Oct 31, 2006 7:31 pm

Sat Dec 02, 2006 11:11 pm

No :cry:
It is not working
 
User avatar
raivis-v
Frequent Visitor
Frequent Visitor
Posts: 55
Joined: Thu Jul 14, 2005 10:21 am
Location: Latvia, Riga

Mon Dec 04, 2006 9:56 am

/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.
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26964
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia
Contact:

Mon Dec 04, 2006 10:28 am

yes exactly, you cannot make a script connect to another router and issue commands on that side.
 
User avatar
Gaougalos
just joined
Topic Author
Posts: 12
Joined: Tue Oct 31, 2006 7:31 pm

Thu Dec 07, 2006 1:09 am

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
 
User avatar
raivis-v
Frequent Visitor
Frequent Visitor
Posts: 55
Joined: Thu Jul 14, 2005 10:21 am
Location: Latvia, Riga

Thu Dec 07, 2006 7:36 am

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.