Community discussions

MikroTik App
 
fusion
just joined
Topic Author
Posts: 18
Joined: Thu Jan 13, 2005 12:38 pm
Location: Czech Republic
Contact:

Command through SSH

Tue Feb 01, 2005 2:18 am

How can I send a command to Mikritik via SSH? For example I want to send this command: /ip service disable telnet. U tried ssh admin@xxx.xxx.xxx.xxx /ip service disable telnet, but no reaction on the router.
 
User avatar
YazzY
Member Candidate
Member Candidate
Posts: 140
Joined: Fri May 28, 2004 3:26 pm
Location: Norway, Østfold
Contact:

Tue Feb 01, 2005 2:58 am

Read this thread:
http://www.mikrotik.com/forum/viewtopic.php?t=1957
It's the one right below yours...
 
fusion
just joined
Topic Author
Posts: 18
Joined: Thu Jan 13, 2005 12:38 pm
Location: Czech Republic
Contact:

Thu Feb 03, 2005 9:09 pm

Yes, I read this topic and I also tried this script. But I use Debian and the script only log to Mikrotik, but then its will freeze. No commands are executed. All required modules are downloaded from CPAN. Did you test it on Debian or have you some advice for me?
 
User avatar
YazzY
Member Candidate
Member Candidate
Posts: 140
Joined: Fri May 28, 2004 3:26 pm
Location: Norway, Østfold
Contact:

Wed Feb 09, 2005 9:46 am

Does it really metter if it's Debian or Solaris or IRIX or MacOS X?
All you need is correct perl path and the required modules.
It works on FreeBSD and Gentoo here.
Bet it'd work on Windows as well.
 
fusion
just joined
Topic Author
Posts: 18
Joined: Thu Jan 13, 2005 12:38 pm
Location: Czech Republic
Contact:

Fri Feb 11, 2005 3:12 am

O.K., now it´s works, there was an error in perl. But now I have another problem. When I run this script on console, it´s OK. But when I want to run it in CRON, the script will freeze. In cron I have "/path/ssh.cmd IP /path/cmd".
 
User avatar
YazzY
Member Candidate
Member Candidate
Posts: 140
Joined: Fri May 28, 2004 3:26 pm
Location: Norway, Østfold
Contact:

Wed Feb 16, 2005 1:07 am

Drop perl, it's bad for you
Run the same thing with expect

#!/usr/bin/expect
#
spawn /usr/bin/ssh host -l user
expect -re "password: "
send "'yourpass\r"
#
expect -re "] > "
send "yourcommand\r"
sleep 2
#
expect -re "] > " exit
 
fusion
just joined
Topic Author
Posts: 18
Joined: Thu Jan 13, 2005 12:38 pm
Location: Czech Republic
Contact:

Fri Feb 18, 2005 8:26 pm

log from cronjob:

spawn /usr/bin/ssh 10.1.2.1 -l stats
stats@10.1.2.1's password:
ip firewall mangle reset-counters
ip?

When I run script on console, everything is working, but still not in cronjob..

Who is online

Users browsing this forum: No registered users and 15 guests