PuTTY only executing the first command in a script specified by -m

4

I try to do a automatic backup of our Avocent Console server.

Content of backup.cmd:

putty.exe -ssh root@acs01.NULL.local -pw secretpw -m acs01.txt

Content of acs01.txt:

cli
cd system_tools/
save_configuration
set ip_address=10.0.0.1
set path_and_filename=/avocent/acs01
set username=ftpacs01
set password=anothersecretpw
save
finish
exit
exit

All works fine, but I have one problem. PuTTY comes only to execute the command cli, all other commands are not executed.

Is it possible to do a short break after each command?

Or is it because the cli is a separate interface in the Avocent?

Thank you

schtebo

Posted 2015-08-25T19:08:57.563

Reputation: 41

What system is the SSH server on? I'm presuming Windows. If so, what's the CLI command directed at? – Jared Allard – 2015-08-25T19:56:11.150

1If you're saying that the cli command starts its own pseudo-shell, then yes, this is the problem. The real shell is likely waiting for the cli processes to complete before continuing with the other commands. If you were to exit the cli application it would probably run the other commands. – heavyd – 2015-08-25T20:06:54.490

2What kind of system is this. What is the cli command. If this is bash, you should not need to put delays in between the commands. – Aaron – 2015-08-25T19:39:37.747

@heavyd any idea what his cli program is? – barlop – 2015-08-25T20:55:07.823

Looks like an Avocent Command Line Configuration Utility

– heavyd – 2015-08-25T20:58:06.310

@heavyd When you say a pseudo-shell, is that just a program that reads from stdin? – barlop – 2015-08-25T21:10:54.273

@barlop, really I just mean an application that acts like a shell, giving you a command prompt, and accepting a limited set of commands, but its probably not as full featured as a shell like bash. – heavyd – 2015-08-25T21:13:56.140

@heavyd I have heard that ssh -T can make a difference between pseudo terminal allocation or not..(-t is forced pseudo terminal, -T is no pseudo terminal) Though when I do ssh -T 127.0.0.1 I get prompted for a password and also without it.. Are you aware of pseudo terminal being toggled in relation to ssh ? (in terms of.. then showing further what is meant by the term)? – barlop – 2015-08-25T21:17:10.927

@barlop, Yeah, I'm aware of of the -T flag and allocating pseudo-TTYs. That is not what I'm talking about, I'm talking about an application that acts like a shell (shell and TTY are different), but is not a real shell. – heavyd – 2015-08-25T21:22:28.280

Let us continue this discussion in chat.

– barlop – 2015-08-25T21:24:01.223

Your should tag your question with appropriate system tag to get more attention from experts on the system. – Martin Prikryl – 2015-08-26T05:09:46.483

Answers

1

If the cli starts a "new shell", the master shell waits for it to exit and never runs your other commands.

Though, you apparently want to run your commands within the cli shell, not after it (maybe except the second exit, which probably should exit the master shell).

For that you have to use an appropriate syntax of your system or an appropriate command-line parameter of cli. You server seems to be some proprietary system, so I do not know the correct syntax. Neither I've found any appropriate command-line parameter of cli in documentation I've found on-line.

On Linux system a generic solution would be:

cli <<EOF
cd system_tools/
save_configuration
set ip_address=10.0.0.1
set path_and_filename=/avocent/acs01
set username=ftpacs01
set password=anothersecretpw
save
finish
exit
EOF
exit

Martin Prikryl

Posted 2015-08-25T19:08:57.563

Reputation: 13 764

0

thanks to all for reply & help. After all, i found a solution. The avocent console server contains 2 alternative commands. Wich do exactly what i need.

saveconf --help restoreconf --help

<

thx + best regards schtebo

schtebo

Posted 2015-08-25T19:08:57.563

Reputation: 41