Send Command From Automated Script to Digi Connect SP

Is there a way to send commands to a digi connect SP device through the ssh command from either a linux shell or from a windows powershell.

Examples:
ssh username@digiconnectsp ‘show user’
echo -e “show\nuser” | ssh username@digiconnectsp

Ok I figured it all out. You need to use expect. Now the way I was able to use it was with python and using pexpect. This will be using linux but I would assume you could do it in windows as well just with different syntax

So I was able to write a simple expect script in python to gather the information I was needing.

Now I did set up ssl keys so I would not have to login with a password.

import pexpect

#this will ssh to the device
child = pexpect.spawn('/usr/bin/ssh root@<ip/hostname>')

# This line means, "Wait until you see a string that matches #> "
child.expect('#> ', timeout=120)

child.sendline('show user') #Send the show user command to get a list of users

#wait for the prompt to come back
child.expect('#> ')

#write it to a file
f = open("/tmp/output.out", "w")
f.write(child.before) #this will write the output before the last expect.  so in our case the output of the show cmd
f.close

child.sendline('quit') #exit out of the device

f.flush() #will force a disk write so it will write the output.out file

Hopefully this helps some people! Cheers