LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Getting "imish" error when executing command on ssh connection. (https://www.linuxquestions.org/questions/linux-networking-3/getting-imish-error-when-executing-command-on-ssh-connection-4175635246/)

jstechg 07-30-2018 05:01 AM

Getting "imish" error when executing command on ssh connection.
 
I need to connect to a cisco switch and execute the command:
show vlan 100

METHOD A:

If I do this manually, it works:
1) I connect with: ssh USER@192.0.0.1
2) When the connection has been established, I type:
show vlan 100
3) The correct information is shown on the screen.



METHOD B:

If I try to do this on a single line to automate the process:
ssh USER@192.0.0.1 "show vlan 100"
The only thing that is shown is this error:
imish: invalid option --'c'
Try 'imish -help' for more information.

But I think that this should work fine. If in a similar way I connect to other PC on the network and I execute "ls -la" this work fine:
ssh USER@192.0.0.20 "ls -la"

So, I think the problem is not in the "ssh" command, but in the "Cisco switch", although I do not know much about this.

Can you help me with this? Any better idea?

Guttorm 07-30-2018 06:02 AM

Hi

I don't know about imish, but it sounds like it's some kind of shell. When you use ssh the way you do, a command like this is executed on the cisco switch:

/bin/sh -c "show vlan 100"

It fails because imish has no -c option. You can add -v to the ssh command to get more info, and even more with -vvv.

You could try piping the command to the shell, for example this:

echo "show vlan 100" | ssh USER@192.0.0.1

And if it doesn't work, you could use expect. People sometimes use expect for login/password, which is usually not a good idea. But it can also be used to get more control when things are complicated.

jlinkels 07-30-2018 07:56 PM

This is the third time you ask something about communication with your switch. In the previous cases you have received ample feedback. The only person not providing feedback was yourself.
Maybe you don't realize it, but we are not a human Google, but instead human volunteers contributing to a community. It is not more than decent if you provide your feedback on the proceedings of your other question and the solutions and recommendations provided.

jlinkels


All times are GMT -5. The time now is 07:11 AM.