Scripting In Putty Error - SSH

This is a discussion on Scripting In Putty Error - SSH ; Hi All, I'm trying desperitly to write code that will work for Putty. Long story short, I'm trying to write a batch file that will launch Putty and read a script file which will run a series of commands. My ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Scripting In Putty Error

  1. Scripting In Putty Error

    Hi All,
    I'm trying desperitly to write code that will work for Putty. Long
    story short, I'm trying to write a batch file that will launch Putty
    and read a script file which will run a series of commands. My setup
    in the batch script is as follows:

    putty.exe -ssh xxx.xxx.xxx.xxx -l Username -pw Password -m lc.txt

    Then, within the contents of the text file I have the following:


    ena
    "Enable Password"
    configure terminal
    interface eth 0/17
    shutdown
    exit
    interface eth 0/23
    shutdown
    exit
    exit
    exit

    It dosn't even get to executing my text file and I recieve the
    following:

    Server refused to start a shell/command.


  2. Re: Scripting In Putty Error

    On May 14, 10:37 am, Richard.Hornber...@susquehanna.net wrote:
    > Hi All,
    > I'm trying desperitly to write code that will work for Putty. Long
    > story short, I'm trying to write a batch file that will launch Putty
    > and read a script file which will run a series of commands. My setup
    > in the batch script is as follows:
    >
    > putty.exe -ssh xxx.xxx.xxx.xxx -l Username -pw Password -m lc.txt
    >
    > Then, within the contents of the text file I have the following:
    >
    > ena
    > "Enable Password"
    > configure terminal
    > interface eth 0/17
    > shutdown
    > exit
    > interface eth 0/23
    > shutdown
    > exit
    > exit
    > exit
    >
    > It dosn't even get to executing my text file and I recieve the
    > following:
    >
    > Server refused to start a shell/command.


    Bump, Please Help!


  3. Re: Scripting In Putty Error

    Richard.Hornberger@susquehanna.net wrote:
    > Hi All,
    > I'm trying desperitly to write code that will work for Putty. Long
    > story short, I'm trying to write a batch file that will launch Putty
    > and read a script file which will run a series of commands. My setup
    > in the batch script is as follows:


    > putty.exe -ssh xxx.xxx.xxx.xxx -l Username -pw Password -m lc.txt


    I'd probably use 'plink' instead of 'putty' for this purpose.

    > Then, within the contents of the text file I have the following:


    > ena
    > "Enable Password"
    > [snip...]


    By examination, I'm going to assume that you're talking to a cisco or
    something like that. The documentation says this:

    3.8.3.6 `-m': read a remote command or script from a file

    The `-m' option performs a similar function to the `Remote
    command' box in the SSH panel of the PuTTY configuration box (see
    section 4.18.1). However, the `-m' option expects to be given a
    local file name, and it will read a command from that file.

    With some servers (particularly Unix systems), you can even put
    multiple lines in this file and execute more than one command in
    sequence, or a whole shell script; but this is arguably an abuse,
    and cannot be expected to work on all servers. In particular, it
    is known _not_ to work with certain `embedded' servers, such as
    Cisco routers.

    I think that means that the Cisco is trying to interpret the entire
    contents of the file as a single command (which doesn't exist).

    I wonder if instead of -m you'd have more luck with:

    plink [...] < lc.txt

    > It dosn't even get to executing my text file and I recieve the
    > following:


    > Server refused to start a shell/command.


    I think it got to it and decided it wasn't a command it wanted to run.

    --
    Darren Dunham ddunham@taos.com
    Senior Technical Consultant TAOS http://www.taos.com/
    Got some Dr Pepper? San Francisco, CA bay area
    < This line left intentionally blank to confuse you. >

  4. Re: Scripting In Putty Error

    >
    > I wonder if instead of -m you'd have more luck with:
    >
    > plink [...] < lc.txt
    >


    I'm not sure if I follow you with the < lc.txt. Forgive but could you
    explain this one? I would be more than glad to try it.


  5. Re: Scripting In Putty Error

    Richard.Hornberger@susquehanna.net wrote:
    >>
    >> I wonder if instead of -m you'd have more luck with:
    >>
    >> plink [...] < lc.txt
    >>


    > I'm not sure if I follow you with the < lc.txt. Forgive but could you
    > explain this one? I would be more than glad to try it.


    '< filename' redirects input from the terminal to a file. I'm fairly
    certain this is true in the windows command interpreter as well.

    So instead using -m to pass the entire file as a command, it acts as if
    you're typing in the contents fo the file to the application locally. I
    have no idea if it works in your situation, but that would be the way
    I'd try it.

    --
    Darren Dunham ddunham@taos.com
    Senior Technical Consultant TAOS http://www.taos.com/
    Got some Dr Pepper? San Francisco, CA bay area
    < This line left intentionally blank to confuse you. >

  6. Re: Scripting In Putty Error

    On May 22, 11:53 am, Darren Dunham wrote:
    > Richard.Hornber...@susquehanna.net wrote:
    >
    > >> I wonder if instead of -m you'd have more luck with:

    >
    > >> plink [...] < lc.txt

    >
    > > I'm not sure if I follow you with the < lc.txt. Forgive but could you
    > > explain this one? I would be more than glad to try it.

    >
    > '< filename' redirects input from the terminal to a file. I'm fairly
    > certain this is true in the windows command interpreter as well.
    >
    > So instead using -m to pass the entire file as a command, it acts as if
    > you're typing in the contents fo the file to the application locally. I
    > have no idea if it works in your situation, but that would be the way
    > I'd try it.
    >
    > --
    > Darren Dunham ddun...@taos.com
    > Senior Technical Consultant TAOS http://www.taos.com/
    > Got some Dr Pepper? San Francisco, CA bay area
    > < This line left intentionally blank to confuse you. >


    Thanks for this, I will have to give it a shot this afternoon.


+ Reply to Thread