How can i create a script that will ssh a device and type some commands?

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers How can i create a script that will ssh a device and type some commands?
# 1  
Old 11-30-2016
How can i create a script that will ssh a device and type some commands?

Hi Guys,
this is the scenario:
ubuntu pc and I have 10 wireless devices that I need to check their firmware version.
I would like to create a script that it will ask me IP, after I enter it, I hit enter then it will show me the version of the firmware.

this is what i do.

Code:
ssh admin@10.0.0.10
admin
admin
show device

The wireless box I use it is not a linux box it has it's commands.

thank you in advance for your help



Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 11-30-2016 at 12:35 PM.. Reason: Added CODE tags.
# 2  
Old 11-30-2016
I don't understand that script, particularly the 'admin' 'admin' part. Are you ssh-ing into a shell or not?
# 3  
Old 11-30-2016
I am using open ssh for windows.


here it is manual example of what i have to type in order to get the info i need

Code:
C:\Users\Gabriel\Desktop\test>ssh admin@192.168.0.5
      0 [main] ssh 12156 find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointer.  Please report this problem to
the public mailing list cygwin@cygwin.com
admin@192.168.0.5's password:

admin connected from 192.168.10.23 using ssh on BreezeWAY
BreezeWay2020> show device
device general product-type COMPACT
device general product-subtype EPC
device general compact-model-type BreezeWAY2020L
device inventory hw-ver 000-03-00
device inventory main-sw-ver 0606.001729
device inventory backup-sw-ver 0606.001607
device inventory running-sw MainSW
device inventory boot-ver 2014.07.00077
device inventory up-time 1970-01-01T00:00:00-00:00
[ok][1970-01-12 23:51:42]
BreezeWay2020>
*** IDLE TIMEOUT ***
Connection to 192.168.0.5 closed.

C:\Users\Gabriel\Desktop\test>


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 11-30-2016 at 01:06 PM.. Reason: Added CODE tags.
# 4  
Old 11-30-2016
So, not a shell.

Can you tell me if this works?

Code:
ssh admin@192.168.0.5 "SHOW DEVICE"

It should still ask you for a password.

I know it's not what you want, I'm still exploring what we're dealing with here.
# 5  
Old 11-30-2016
Do you have any file access to these wireless devices?
# 6  
Old 11-30-2016
I just tried what you said and it never got the prompt to keep typing
I have to press CTRL+C to abort

---------- Post updated at 12:38 PM ---------- Previous update was at 12:36 PM ----------

that is all the access customer have to this kind of devices
# 7  
Old 11-30-2016
That is unfortunate. With no way to copy SSH keys to these devices, you'll have to use something like the expect brute-forcing tool to automate them.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Create a UNIX script file with multiple commands

Hi Good morning all, I want to create script file with multiple commands. For ex: pmrep connect is one of the command to connect to repository. pmrep objectexport is another command to export objects to a file. These commands should run sequentially.But when i try to execute this, the first... (4 Replies)
Discussion started by: SekhaReddy
4 Replies

2. Shell Programming and Scripting

How to create an executable bash script for these commands?

I wish to create an executable bash script that will run the following commands as root, that is, using sudo su iptables-save | awk '/^ / { print $1 } /^:+ / { print $1 " ACCEPT" ; } /COMMIT/ { print $0; }' | iptables-restoreMy first attempt at bash... (9 Replies)
Discussion started by: thixeqi
9 Replies

3. Shell Programming and Scripting

Script which telnets to a device, runs commands and prints output to a file

I am connecting to a device using telnet, I want my script to perform certain commands : ie- show device , show inventory..etc and write the output it sees from the terminal to a file. this is what I have got : #!/usr/bin/expect -- set running 1 spawn telnet <ip address> expect ... (1 Reply)
Discussion started by: samantha123
1 Replies

4. Shell Programming and Scripting

Running script and commands through SSH

Hello All, I am trying to run some simulations through SSH from my mac on our university SOLARIS system. My problem is that whenever I want to execute a command I get an error which says "Invalid argument". Maybe I should explain more what I want to do and what I did. Firstly I installed a... (10 Replies)
Discussion started by: Apfik
10 Replies

5. Shell Programming and Scripting

Execute ssh commands through bash script

Hi all! I am trying to write a script that will check if a certain directory is available at several different nodes and then do stuff in it ..... On the beginning of the script I give as a variable the directory and the number of the nodes and then I loop like this: for... (3 Replies)
Discussion started by: idet2
3 Replies

6. Shell Programming and Scripting

Create a list of commands in a central location, and then run them all remotely through a ssh here

I'm trying to write a script that in the end will from one central location hop to a bunch of servers and then run a series of ping tests. The thing is, the list of devices that needs to be pinged is going to be different for each server. So what I want to do is be able to do is read through the... (0 Replies)
Discussion started by: DeCoTwc
0 Replies

7. Shell Programming and Scripting

to create a phone book using shell script and unix commands

can you help me to create a phone book with add, delete, modify with first name, last name, middle name, phone no(multiple ph no), address, email address, notes or comments to store about the contact and groups that hold for the contact.. i am new to this linux environment. please guide me. ... (1 Reply)
Discussion started by: monster11209
1 Replies

8. Shell Programming and Scripting

Using tab in script to create file of commands

from CLI pressing Tab and character like a shows result of the commands starting with a, can i use this in a script too and post the results to a file? thanks (1 Reply)
Discussion started by: tvrman
1 Replies

9. Shell Programming and Scripting

Adding ssh commands to a shell script

I have written some scripts that do a few admin tasks on 23 servers I manage. Usually I execute these scripts from one server by running ssh commands remotley, i.e. ssh root@server2 shellscript, ssh root@server2 shellscript & so on.. It works fine but I want to improve this by writing a... (3 Replies)
Discussion started by: Moxy
3 Replies

10. Shell Programming and Scripting

Modifying simple commands to create a script

Can anyone direct me to a resource that explains scripting in simple terms? I have visited many sites and browsed this forum and have yet to find simple explanations. (8 Replies)
Discussion started by: rocinante
8 Replies
Login or Register to Ask a Question