Problems with Putty + CLI + Commands

(Peter) #1

Hello, i’m completely a newbie. I have a server 1 and a server 2. On server 1 there is windows server 2016 and i installed putty. On server 2 there is freepbx distro. On server 1 i started putty (plink) with a batchfile. I’nm doing this because i want to transfer CLI-commands via putty to server 2.

The content of the batchfile is:
C:\plink.exe -ssh root@xx.90.201.xx -pw mypassword -m “c:\xx.txt” -t -batch

In the file xx.txt i enter the command to open the CLI console:
asterisk -r

Ok, this works, but my problem is, that now i want to add another CLI commands like:
confbridge list
confbridge kick 100 all

So i change the xx.txt file like:
asterisk -r
confbridge list
confbridge kick 100 all

But this doesn’t work. Can somesome help me? Please explain what to do in a very simply way, because i’m only a beginner. Than you very much.


I don’t believe that plink (or ssh) can send input to a remote command that way, because it waits for a command to finish before sending the next one. asterisk -r doesn’t finish; it’s waiting for user input.

Try replacing the contents of xx.txt with
asterisk -rx 'confbridge list'
asterisk -rx 'confbridge kick 100 all'

You could also just put the remote commands in the plink call, e.g.

plink -ssh root@xx.90.201.xx -pw mypassword -t -batch "asterisk -rx 'confbridge list'"

If you have set up a saved session with RSA authentication, you could use
plink -batch mypbx "asterisk -rx 'confbridge list'"