GithubHelp home page GithubHelp logo

sshlibrary's Introduction

SSHLibrary

Introduction

SSHLibrary is a Robot Framework test library for SSH and SFTP. The project is hosted on GitHub and downloads can be found from PyPI.

SSHLibrary is operating system independent and supports Python 2.7 as well as Python 3.4 or newer. In addition to the normal Python interpreter, it also works with Jython 2.7.

The library has the following main usages:

  • Executing commands on the remote machine, either with blocking or non-blocking behavior.
  • Writing and reading in an interactive shell.
  • Transferring files and directories over SFTP.
  • Ensuring that files and directories exist on the remote machine.

image

image

Documentation

See keyword documentation for available keywords and more information about the library in general.

For general information about using test libraries with Robot Framework, see Robot Framework User Guide.

Installation

The recommended installation method is using pip:

pip install --upgrade robotframework-sshlibrary

Running this command installs also the latest Robot Framework, paramiko and scp versions. The minimum supported paramiko version is 1.15.3 and minimum supported scp version is 0.13.0. The --upgrade option can be omitted when installing the library for the first time.

With recent versions of pip it is possible to install directly from the GitHub repository. To install latest source from the master branch, use this command:

pip install git+https://github.com/robotframework/SSHLibrary.git

Alternatively you can download the source distribution from PyPI, extract it, and install it using one of the following depending are you using Python or Jython:

python setup.py install
jython setup.py install

A benefit of using pip is that it automatically installs scp, paramiko and Cryptography modules (or PyCrypto if paramiko version < 2.0) that SSHLibrary requires on Python.

On Jython, SSHLibrary requires Trilead SSH JAR distribution. You need to download Trilead SSH JAR distribution and add it to CLASSPATH.

On Windows operating system, when using Python version < 3.0, SSHLibrary will require win_inet_pton. The minimum supported win_inet_pton version is 1.1.0.

For creating SSH tunnels robotbackgroundlogger > 1.2 is also a requirement.

Docker

When installing SSHLibrary in a container (eg. Alpine Linux) there are more dependencies that must be installed: gcc, make, openssl-dev, musl-dev and libffi-dev. These packages can be installed using:

apk add gcc make openssl-dev musl-dev libffi-dev

Usage

To use SSHLibrary in Robot Framework tests, the library needs to first be imported using the Library setting as any other library.

When using Robot Framework, it is generally recommended to write as easy-to-understand tests as possible. The keywords provided by SSHLibrary are pretty low level and it is typically a good idea to write tests using Robot Framework's higher level keywords that utilize SSHLibrary keywords internally. This is illustrated by the following example where SSHLibrary keywords like Open Connection and Login are grouped together in a higher level keyword like Open Connection And Log In.

*** Settings ***
Documentation          This example demonstrates executing a command on a remote machine
...                    and getting its output.
...
...                    Notice how connections are handled as part of the suite setup and
...                    teardown. This saves some time when executing several test cases.

Library                SSHLibrary
Suite Setup            Open Connection And Log In
Suite Teardown         Close All Connections

*** Variables ***
${HOST}                localhost
${USERNAME}            test
${PASSWORD}            test

*** Test Cases ***
Execute Command And Verify Output
    [Documentation]    Execute Command can be used to run commands on the remote machine.
    ...                The keyword returns the standard output by default.
    ${output}=         Execute Command    echo Hello SSHLibrary!
    Should Be Equal    ${output}          Hello SSHLibrary!

*** Keywords ***
Open Connection And Log In
   Open Connection     ${HOST}
   Login               ${USERNAME}        ${PASSWORD}

Support

If the provided documentation is not enough, there are various support forums available:

sshlibrary's People

Contributors

andreeakovacs avatar bachng2017 avatar benigroza avatar brian-williams avatar claudiudragan avatar cristii006 avatar freddebacker avatar helioguilherme66 avatar jsdobkin avatar jussimalinen avatar kallepokki avatar laurentbristiel avatar marcinet avatar mihaiparvu avatar mika-b avatar mkorpela avatar noordsestern avatar pekkaklarck avatar rainmanwy avatar ricualex avatar rticau avatar spooning avatar stefanmewa avatar tattoo avatar tirkarthi avatar urundead avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sshlibrary's Issues

Add possibility to configure shell/terminal size in `Open Connection`

Originally submitted to Google Code by lones... on 7 Jun 2012

  1. use Login keyword, login to SSH server
  2. use Write keyword to run command which will generate some long output,
    so that the output length exceed the $LINES of terminal, then:
  3. ${output} = Read Until Prompt

I found the ${output} is different from what I get by typing command manually in terminal, the ${output} is mess.

e.g.
when you execute the command manually in xterm SSH, you get:

Name Sex Age Title Department

lonestep Male 90 Noob NewBieLab

but the same command in robotframework-sshlibrary you get:

Name Sex Age Tit Departm

le ent

Shawn Male 90 No NewBie
ob Lab

VERSION:robotframework-sshlibrary 1.0
OS: Ubuntu 12.04 LTS

I don't know what is the underlaying dependencies of the ssh, does the output depend on terminal size of client? or ssh server's terminal setting? I found no document and no solution on web, and the output is just mess.

Enhance documentation of keywords that can execute commands

Originally submitted to Google Code by @pekkaklarck on 11 Aug 2010

I needed to explain how different keywords that execute commands work in a mail. This stuff could be added to the keyword documentation:

> I have many testcases where I execute UNIX commands via
SSHLibrary. In some
> of them I need to evaluate the output of a command. SSHLibrary
provides several
> keywords / keyword combinations which could be used for that:
>
> - Write | <UNIX command>
> ${output}= | Read

This reads everything currently available in the output buffer. Good if
you know everything has been written, not so good if the command is
still writing something.

> - Write | <UNIX command>
> ${output}= | Read Until Prompt

This reads everything until the next prompt (that must have been set
earlier) appears in the output buffer. If there's no prompt initially,
this will wait for it to appear until the configured timeout. Good when
you have started a command when the output buffer was empty and are
waiting for the to finish. Bad if there are already prompts in the
output buffer or the command produces multiple buffers.

> - Write Bare | <UNIX command> \n
> ${output}= | Read
>
> - Write Bare | <UNIX command> \n
> ${output}= | Read Until Prompt

These are identical to the previous commands. You are just adding the
newline character yourself -- Write adds that automatically but Write Bare doesn't.

> - Start Command | <UNIX command>
> ${output}= | Read Command Output

I didn't even know that there are a keywords like these in SSHLibrary.
Apparently they start the command on background and you can then read it
later.

> - ${output}= | Execute Command | <UNIX command>

This one executes the command in a separate shell. Easiest to use but
not possible when you need to run several shell commands.

Selenium remote controller not closed with IE7

Originally submitted to Google Code by jarno.ka... on 18 Apr 2012

What steps will reproduce the problem?
1.create test that starts selenium server, open IE browser, does few actions, closes browser.
2.run it
3.when test is run and main window is closed, remote cotnrol window is not. test stops there until manually window is closed. in Firefox it works ok.

What is the expected output? What do you see instead?
remote controller is closed when main window is closed.

What version of the product are you using? On what operating system?
Windows XP(32bit), IE 7, python 2.7.3, RIDE 0.43.3, RFW 2.7.1_win32, wxPython2.8.win32 unicode-2.8.12.1-py27, selenium library 2.8.1.win32

Please provide any additional information below.
libraries in use:Selenium library, String, OperatingSystem
basic script is below
start selenium server
Start selenium server

http_IE_simple
Set selenium timeout 15
Open Browser www.google.fi ie
Maximize Browser Window
sleep 5s
Close browser

stop selenium
Stop Selenium Server

Possibility to run commands via ssh

Originally submitted to Google Code by tatu.kairi on 4 Nov 2011

I would like to run a command via ssh from Robot. Reading documentation, it seems that with SSHLibrary, it is not possible to run the equivalent of:

:~$ ssh user@⁠remote.place.com ls

and get back the output

Or am I missing something? If I'm not, can this functionality be done?

Login problem with the keyword With Public Key without password

Originally submitted to Google Code by jrvilda on 10 Jan 2012

According to documentation:

Logs into SSH server with given information using key-based authentication.
username is the username on the remote system.
keyfile is a path to a valid OpenSSH private key file.
password is used to unlock keyfile if unlocking is required.

if unlocking si not required:
Keyword 'SSHLibrary.Login With Public Key' expected 3 arguments, got 2.

Path separator of the target machine should be configurable

Originally submitted to Google Code by sylvain.hellegouarch on 27 Jul 2011

Let's say you have this test:

*** Settings ***
Library SSHLibrary

*** Variables ***
${HOST} <SOME IP>
${USERNAME} <SOME USER>
${PWD} <SOME PWD>

*** Test Cases ***
Failing to copy a file on a Windows machine
Open Connection ${HOST}
Login ${USERNAME} ${PWD}
Put File test.txt c:\windows\temp\test.txt
Close Connection

When you run this with Robot Framework you get something alone:

KEYWORD: SSHLibrary.Put File test.txt, c:\windows\temp\test.txt
Documentation: Copies file(s) from local host to remote host using existing SSH connection.
Start / End / Elapsed: 20110727 16:01:42.091 / 20110727 16:01:42.183 / 00:00:00.092
16:01:42.164 INFO Creating missing remote directory 'windows'
16:01:42.183 FAIL IOError: [Errno 2] The file path does not exist or is invalid.

Now if you take this:

from SSHLibrary import SSHLibrary

all = ['SSHLib']

class SSHLib(SSHLibrary):
ROBOT_LIBRARY_SCOPE = 'GLOBAL'

def put_one_file(self, source, destination='.', mode='0744', newlines='default'):
    self._client.create_sftp_client()
    try:
        self._info("Putting '&#37;s' to '&#37;s'" &#37; (source, destination))
        self._client.put_file(source, destination, int(mode, 8),
                              {'CRLF': '\r\n', 'LF': '\n'}.get(newlines, None))
    finally:
        self._client.close_sftp_client()

if name == 'main':
ssh = SSHLib()
ssh.open_connection("192.168.0.66")
ssh.login("test", "test")
ssh.put_one_file("test.txt", "c:\windows\temp\test.txt")
ssh.close_connection()

It will succeed copying the file.

It appears that the top-level Put File keyword performs some operations on the path that aren't handled well with Windows.

Python 2.7
Robot Framework 2.5.7
SSH Library 1.0
Paramiko 1.7.7.1
PyCrypto 2.3
Windows 2008

prompt assignment is not working. Provide example on how to execute interactive scripts in ssh?

Originally submitted to Google Code by sriharshatn on 16 Feb 2012

What steps will reproduce the problem?
Open Connection <ip address>
Login <username> <password>
${prompt} set prompt #
${result} start command mysql
log ${result}
${result} write exit
log ${result}
Close Connection

Also as per below example prompt assignment to scalar is not working
${prompt} Set Prompt $
Do Something
Set Prompt ${prompt}

What is the expected output? What do you see instead?
${prompt} =
has no variable assignment
Log is attached. I want to interactively execute sql statements and exit from mysql.
Pls suggest how this can be done?

What version of the product are you using? On what operating system?
pybot --version
Robot Framework 2.5.4 (Python 2.6.2 on win32)

Please provide any additional information below.
Also unable to end the command execution if logging in to mysql through the mysql command.

Make SSH Library one of the RF standard libraries

Originally submitted to Google Code by @pekkaklarck on 5 Feb 2009

It was good to keep SSH Library out of the Robot Framework core when it was
developed so that new releases could be created independently.
The library is pretty stable these days, so this reason isn't really valid
anymore.

Another reason to keep it as an external library is that it needs some
preconditions. This reason isn't that valid either because it isn't easy
bundle preconditions and users anyway need to install them separately.
Having SSH Library as a standard library under RF would thus ease taking it
into use.

Enable SSH Logging keyword should log things before connecting

Originally submitted to Google Code by tomi.h.t... on 16 Feb 2009

What steps will reproduce the problem?

  1. In test case use Enable SSH Logging keyword
  2. In test case use incorrect credentials in logging into server
  3. Run the test suite

What is the expected output? What do you see instead?

There should be created the given log file with error message of incorrect
credentials, and the failing keyword should be Login.

Now the failing keyword is Enable SSH Logging, and there is only in
log.html written:
FAIL AttributeError: 'NoneType' object has no
attribute 'enable_ssh_logging'

What version of the product are you using? On what operating system?

Robot framework 2.0.4 with SSH Lib 0.8 on linux RHEL 4

Execute Command not executing or starting an application and or shell script that starts an application

Originally submitted to Google Code by mr.kevin.chong on 12 Jan 2012

What steps will reproduce the problem?

  1. SSHLibrary.Open Connection ${Host}
  2. SSHLibrary.Login ${RootUsername} ${RootPwd}
  3. SSHLibrary.Execute Command ${command}

Where ${command} is one of the following:
1.
on -d startlogger 2>&1
2.
startlogger
3.
a shell scrip that has the same command without escape characters

What is the expected output? What do you see instead?
I expect it to start the startlogger application but instead it says that it has been executed and that is it. I use the same command and procedures for other tasks and they work fine. Including running commands off a shell script. However, for some reason I cannot get it to start.

I can telnet into the unit manually and startlogger by using the commands above but for some reason, it doesnt allow this particular app to run via Execute command.

Does anyone have a workaround for this? Or anyway to troubleshoot this issue?

What version of the product are you using? On what operating system?
SSHLibrary: 1.0
Windows 7, 64 bit
Robot Framework 2.6.3
Jython 2.5.2

Please provide any additional information below.
As mentioned above, I am able to run shell scripts but I just cannot get it to run applications. Any help would be greatly appreciated.

Add optional parameter `newlines` to `Put File` keyword

Originally submitted to Google Code by gerhard.heil on 11 Aug 2010

If a textfile is transferred via PutFile from a Windows machine to a UNIX machine, the target file contains Ctrl-M´s.

An optional parameter to specify the transferMode would be helpful.

Used version: SSHLibrary 0.9

Jybot execution hangs sometimes

Originally submitted to Google Code by tomi.h.t... on 27 Feb 2009

What steps will reproduce the problem?

  • Happens only every now and then. Can't be reproduced on purpose. Quite
    rare situation.

What is the expected output? What do you see instead?

  • Execute Command should return in any case after a while.
  • Now the execution gets hanging some times, if jybot is used. The reason
    for hanging is not known.

What version of the product are you using? On what operating system?

  • Robot framework 2.0.4 & SSH Lib 0.8 on Linux RHEL 4

Please provide any additional information below.

  • Sent a patch for the thread approach to Robot devel list on 26.2.2009.

I can not use spec file though I generated it successfully.

Originally submitted to Google Code by docon... on 3 May 2011

What steps will reproduce the problem?
1.I import a libary written by java like this: lib/TestForRF.java
2.generated a spec file before as follow:
<?xml version="1.0" encoding="UTF-8"?>
<keywordspec generated="20110429 17:50:11" type="library" name="TestForRF">
<version>&amp;lt;unknown&amp;gt;</version>
<scope>test case</scope>
<doc/>
<kw name="Get Service IP">
<doc/>
<arguments>
</arguments>
</kw>
<kw name="Is Match">
<doc/>
<arguments>
<arg>l</arg>
</arguments>
</kw>
<kw name="Test 123">
<doc/>
<arguments>
</arguments>
</kw>
<kw name="Test Aarry">
<doc/>
<arguments>
</arguments>
</kw>
<kw name="Test List">
<doc/>
<arguments>
</arguments>
</kw>
</keywordspec>

  1. set PYTHONPATH="E:**\lib",start ride in the parent directory of lib.
    but key completion function doesn't work.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Version 0.35.1 running on Python 2.6.6 using Robot Framework 2.5.7.
jdk1.6.0_24

Please provide any additional information below.

Insufficient error reporting

Originally submitted to Google Code by SonOfLilit on 30 Oct 2008

When something goes wrong in the SSH session (as simple as telling it to
copy a file that doesn't exist) there is no reporting and no crashing.

This makes it very hard to figure out what went wrong when a test failed,
and in some cases even creates false positives.

Is there a plan to improve exception throwing and error reporting?

For one, I would advise enabling the paramiko log (or adding a keyword to
enable it):

def __init__(self, host, port=22):
    paramiko.util.log_to_file('paramiko.log')

Above that, there are loads of error handling code that has to be written.
You may assign it to me, but I would probably be very slow about it as I
have many other roles at my company.

p.s. How do I mark an issue as "Enhancement"?

Add keyword "Copy File" to mimick RF OperatingSystem library

Originally submitted to Google Code by roal.zan... on 13 Jun 2012

Enhancement request.

It would be great to have "Copy File" keyword similar to the one in OperatingSystem library (and, maybe, replace "Get File" and "Put File" altogether).

http://robotframework.googlecode.com/hg/doc/libraries/OperatingSystem.html?r=2.7.2#Copy File

What version of the product are you using? On what operating system?
$ pybot --version
Robot Framework 2.7.1 (Python 2.7.3 on linux2)
SSHLibrary verion 1.0

SSHLibrary Write fails when prompt is not set

Originally submitted to Google Code by marcinet on 21 Jul 2008

What steps will reproduce the problem?

  1. Open SSH connection and login to Linux machine
  2. Write 'ls' (or any other string)

What is the expected output? What do you see instead?
Expected output: clear error message, like 'Write failed, use Set Prompt first'

Instead, I get:

08:38:57.197 TRACE Arguments: [ write ]
08:38:57.526 INFO Writing 'write\n'
08:38:57.526 INFO Opening new channel
08:38:57.526 FAIL TypeError: expected a character buffer object
08:38:57.526 INFO Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\SSHLibrary__init__.py", line 271, in
write
self.write_bare(text)
File "C:\Python25\Lib\site-packages\SSHLibrary__init__.py", line 283, in
write_bare
self.client.write(text, self._prompt)
File "C:\Python25\Lib\site-packages\SSHLibrary\pythonclient.py", line 66,
in write
print 'INFO %s' % self.read_until(prompt, 30)
File "C:\Python25\Lib\site-packages\SSHLibrary\pythonclient.py", line 83,
in read_until
if data.count(expected) > 0:

What version of the product are you using? On what operating system?
lib 0.5 + Windows XP. Same behaviour on Linux

Please provide any additional information below.

Error in javaclient.py @ line 17

Originally submitted to Google Code by damon.... on 10 May 2011

What steps will reproduce the problem?

  1. running a Robot Framework script that uses the SSHLibrary
    2.
    3.

What is the expected output? What do you see instead?
THe SSHLibrary should have loaded.

[ ERROR ] Error in file '/home/dhermann/r7/v4/automation/qa/resources/ui/HostInfo/HostInfoKeywords.tsv' in table 'Setting' in element on row 4: Importing test library 'SSHLibrary' failed: SyntaxError: invalid syntax (javaclient.py, line 17)
PYTHONPATH: ['/usr/local/lib/python2.6/dist-packages', '/usr/local/lib/python2.6/dist-packages/robot/libraries', '/usr/share/jython/Lib', '/usr/lib/site-python', 'classpath', '.']

[ ERROR ] Error in file '/home/dhermann/r7/v4/automation/qa/resources/ui/HostInfo/HostInfoKeywords.tsv' in table 'Setting' in element on row 4: Importing test library 'SSHLibrary' failed: SyntaxError: invalid syntax (javaclient.py, line 17)
PYTHONPATH: ['/usr/local/lib/python2.6/dist-packages', '/usr/local/lib/python2.6/dist-packages/robot/libraries', '/usr/share/jython/Lib', '/usr/lib/site-python', 'classpath', '.']

What version of the product are you using? On what operating system?
OS: Ubuntu 10.2
python2.6
jython2.5.1
SSHLibrary 1.0
trilead-ssh2-build213.jar
Robot Framework .22
java 1.6.024

Please provide any additional information below.

This seems to work fine in cygwyn on a windows vm. We have a serious need to run this under ubuntu. So, ANY help you can give me will be really appreciated.

If I have missed any information you needed, please let me know and I will add what ever you need.

Thanks a mil!

Backgrounding (via &) keeps command open and does not proceed to next step

Originally submitted to Google Code by mr.kevin.chong on 4 Oct 2011

What steps will reproduce the problem?

  1. Connect device using SSH
  2. Login
  3. Execute command, cat changingFile?wait &

What is the expected output? What do you see instead?
I expect that it will automatically start the next test step

What version of the product are you using? On what operating system?
1.0.0 of SSHlibrary, on 2.6.2 of RF on windows XP

Please provide any additional information below.
I'm trying to monitor a file by using cat and wait. by using that, I want to use a variable that is passed through to manipulate directories that i will verifying against.

However, when I run my script, I cannot run the next step until I kill the process.

I have tried 'exit 0' with no luck. The only way it will advance to the next test is if i slay the command (which I do not want to do until I get the monitoring information that I need)

If anyone has a solution or a workaround in the meanwhile, it will be greatly appreciated!

SSHException: No suitable address family for 10.1.1.1

Originally submitted to Google Code by marcinet on 31 Aug 2009

What steps will reproduce the problem?

  1. Install paramiko 1.7.5 (works with 1.7.4)
  2. Try to connect to the server using IPv4 address (e.g. 10.1.1.1)
    3.

What do you see instead?
SSHException: No suitable address family for 10.1.1.1
Traceback (most recent call last):
File "c:\python26\lib\site-packages\SSHLibrary__init__.py", line 191, in
login
self._client.login(username, password)
File "c:\python26\lib\site-packages\SSHLibrary\pythonclient.py", line 48,
in login
self.client.connect(self.host, self.port, username, password)
File "c:\python26\lib\site-packages\paramiko\client.py", line 283, in connect
raise SSHException('No suitable address family for %s' % hostname)

What version of the product are you using? On what operating system?
Windows XP, Paramiko 1.7.5, pycrypto 2.0.1, Robot 2.1.1, pybot

Please provide any additional information below.

Prompt should be set per connection

Originally submitted to Google Code by psofiamo... on 25 Nov 2010

What steps will reproduce the problem?
1.SSH Login
2.Set Prompt #
3. Close Connection
4. SSH Login in other Test case (for example default prompt should be '>')
5. Fails, Read Until Prompt is waiting for the # (set by the previous test).

What is the expected output? What do you see instead?
Login should be successful, but instead fails due of setting in a previous test case the prompt. Close Connection should clean up this.

What version of the product are you using? On what operating system?
Robot Framework 2.5.1
SSH Library Version 1.0

Please provide any additional information below.
I notice this problem after upgrading to the new SSH lib version.
There should be a way to reset the prompt after closing the connection.

At report the "Login" related reports must not include password

Originally submitted to Google Code by teme.temppuilija on 19 May 2009

At the moment the log.html includes pass word when login has been called.
This is not good idea as even the test-servers quite often has password and
user right protections.

So instead of having:

KEYWORD: SSHLibrary.Login teme, temespassword

there should be

KEYWORD: SSHLibrary.Login teme, ****** (that amount of stars should be fixed)

create_missing_remote_path case sensitive on windows

Originally submitted to Google Code by SonOfLilit on 5 Nov 2008

def create_missing_remote_path(self, path):
    if path == '.':
        return
    if os.path.isabs(path):
        self.sftp_client.chdir('/')
    else:
        self.sftp_client.chdir('.')
    for dirname in path.split('/'):
        if dirname and dirname not in

self.sftp_client.listdir(self.sftp_client.getcwd()):
print "INFO Creating missing remote directory '%s'" % dirname
self.sftp_client.mkdir(dirname)
self.sftp_client.chdir(dirname)

If I have a directory "C:\Temp" and try to copy "localfile" into
"c:\temp\dir\file", I get a "bad message" error for trying to create the
directory "/temp".

This is where I discovered it, but I'm sure it appears elsewhere too.

SSHLibrary really doesn't work well with Windows, the code simply has to be
read once or twice while thinking about portability (or it should be
declared not supporting windows). I don't know enough python to be the one
to do it...

-- Aur

Get file silently fails when windows server (includes patch)

Originally submitted to Google Code by SonOfLilit on 24 Sep 2008

What steps will reproduce the problem?

  1. Connect to a windows SSH server (I use freeSSHd)
  2. Call Get Files keyword

What is the expected output? What do you see instead?
I expect the file to appear where I told it to on my hard drive. I get a
silent failure.

The problem is caused in pythonclient.py listfiles():

def listfiles(self, path):
    return[ getattr(fileinfo, 'filename', '?') for fileinfo 
            in self.sftp_client.listdir_attr(path)
            if stat.S_ISREG(fileinfo.st_mode)]

As you can see, if paramiko returns a fileinfo object that has no st_mode
property - bang! we get an empty file list.

The fix:

--- pythonclient.py
+++ pythonclient.py
@⁠@⁠ -107 +107 @⁠@⁠

  •            if stat.S_ISREG(fileinfo.st_mode)]
    
  •            if fileinfo.st_mode == None or stat.S_ISREG(fileinfo.st_mode)]
    

(patch generated by hand)

Also, Get File behaves very strangely with paths.

That is mainly due to these lines:
init.py, 518
def _get_get_file_sources(self, source):
path, pattern = posixpath.split(source)
if not path:
path = '.'
sourcefiles = []
for filename in self._client.listfiles(path):
if utils.matches(filename, pattern):
if path:
filename = posixpath.join(path, filename)
sourcefiles.append(filename)
return sourcefiles

Notice the POSIX path joins which don't work, um, very well with windows.

I'm have 0 python experience and would probably break something if I try to
fix it.

-- Aur

Enhance `Execute Command` to also return return code if requested

Originally submitted to Google Code by roal.zan... on 13 Jun 2012

What steps will reproduce the problem?

  1. Open Connection ${HOST}
  2. Login ${USER} ${PASSWORD}
  3. Execute Command false

What is the expected output? What do you see instead?
There's no simple and direct way to get the RC of the remotely execute command.

What version of the product are you using? On what operating system?
$ pybot --version
Robot Framework 2.7.1 (Python 2.7.3 on linux2)
SSHLibrary verion 1.0

Please provide any additional information below.
Suggestion: add a "Execute Command and Return RC" keyword or something like

keepalive ssh connect by sending null packets to server until timeout reach

Originally submitted to Google Code by zhangjia... on 23 Apr 2012

What steps will reproduce the problem?

  1. Create ssh connect and set timeout as 10 min
  2. But remote *nix server will disconnect any idle client and terminating the session if no data has been received from client longer than 5 min. But my script on remote server will take 10 min to finish.

What is the expected output? What do you see instead?
We are hoping that ssh lib can help us send null packets to the remote server so that the connection can keepalive before timeout value reached.

What version of the product are you using? On what operating system?
SSH 1.0. robot is running on Windows XP.

Please provide any additional information below.
putty can provide the similiar function by setting the interval seconds to the option "Sending of null packets to keep session active".

Timeout given to __init__ cannot be "time string"

Originally submitted to Google Code by @pekkaklarck on 20 Feb 2009

Timeout given to init can only be an integer or a string that can be
converted to an integer. It should be possible to give it also as "time
string" like "1 minute 10 seconds". This format is already supported by
set_timeout, and init can use that as a helper.

Installation using in `zc.buildout` fails

Originally submitted to Google Code by supam... on 27 Jun 2012

What steps will reproduce the problem?
Error while install library with zc.buildout - in setup.py line "import SSHLibrary" is cause of error. The error happens because zc.buildout use system python.

Clear requirement for paramiko, pycrypto and trilead in Installation Guide

Originally submitted to Google Code by marcinet on 5 Feb 2009

When installing SSHLibrary, people keep complaining that 'SSHLibrary
doesn't work'. This is because they don't install Paramiko and Pycrypto.
It looks like it is not stated clearly enough in the installation
instructions that it is required.
Proposed solution:

  • make requirement for Paramiko, Pycrypto and Trilead more explicit
    (perhaps even on the main page)
  • provide clear error message when paramiko or trilead is not there

SSH Autocomplete not available by defualt

Originally submitted to Google Code by vineeshp on 10 Feb 2011

What steps will reproduce the problem?
1.Install the Framework and SSH Library
2.Start RIDE.
3.Include SSH Library in a testcase. Try to autocomplete

What is the expected output? What do you see instead?
Since the library is included, it should automatically complete the keyword. or Pressing CTRL should display documentation.

What version of the product are you using? On what operating system?
RF 2.5.6 (Seen this in previous releases also.) Ride 32.1. SSH Library 1.0. Python 2.7.
OS: on Windows XP

I have worked around this by manually copying this file from an old installation where it used to work.

Registered as `SSHLIbrary` on PyPI when it should be `robotframework-sshlibrary`

Originally submitted to Google Code by bocadillodeatun on 11 Jun 2012

The next command does not work:

#sudo pip install robotframework-sshlibrary

It looks like the package has not been properly registered with the PyPI index.

For now, a workaround for this is to manually give the whole path to the dist file, like this:

sudo pip install https://robotframework-sshlibrary.googlecode.com/files/SSHLibrary-1.0.tar.gz

... but it would be nice if you could update the "PyPI" index with the proper pointer.

Thanks.

Error message should be better if connection lost during testing also other keywords than Enable SSH Logging

Originally submitted to Google Code by tomi.h.t... on 17 Feb 2009

What steps will reproduce the problem?

  1. Connection to remote host is lost during testing
  2. Use after that e.g. Execute Command keyword

What is the expected output? What do you see instead?

There should be descriptive error message of lost connection.
At the moment there is said only
FAIL AttributeError: 'NoneType' object has no attribute 'exec_command'

What version of the product are you using? On what operating system?

Robot framework 2.0.3 SSH lib 0.8 on linux RHEL 4

Provide public key authentication keyword for login

Originally submitted to Google Code by tomi.h.t... on 16 Feb 2009

What steps will reproduce the problem?

  1. There should be a keyword for using public key authentication

What is the expected output? What do you see instead?

Public keys should be possible to be used in logging in to remote servers
instead of passwords.

What version of the product are you using? On what operating system?

Robot framework 2.0.4 SSH Lib 0.8 on linux RHEL 4

Please provide any additional information below.

There is sent a patch to the robot-devel that does the trick.

How to login outside SSH server ?

Originally submitted to Google Code by aloha.in... on 2 Nov 2011

What steps will reproduce the problem?

  1. vim resources/user_information.py
  2. vim resources/ssh_library_resource.txt (as same as your atest/resources)
  3. vim myFirstSSHTest.txt

What is the expected output? What do you see instead?

Login successfully , but I see
No match found for '$' in 3 seconds

What version of the product are you using? On what operating system?

sshlibrary 1.0
Ubuntu 11.10

Please provide any additional information below.
I do not change ssh_library_resource.txt .
I just change user_information.py file , as below

HOST = "my.server.ip"
USERNAME = "test"
PASSWORD = "password"

and my myFirstSSHTest.txt as below

Settings
Resource resources/ssh_library_resource.txt

Test Case
Test Opening and Closing Connection
Open Connection ${HOST}
Login ${USERNAME} ${PASSWORD}
Close All Connections

Sorry about that I am a novice ~
Is there any wrong?
or The problem is about , if i try login manually , it will show

The authenticity of host 'my.server.ip. ' can't be established.
RSA key fingerprint is 31:4f:de:8f:0e:0a:61:6a:fc:c0:fb:8e:e7:62:6f:c0.
Are you sure you want to continue connecting (yes/no)?

sorry to bother you ~
But thanks a lot

SSHLibrary.Execute Command ---- AttributeError: 'NoneType' object has no attribute 'exec_command'

Originally submitted to Google Code by dengyike on 27 Dec 2009

Hi:
I meet a problem several time, when my testcase involve
"SSHLibrary.Execute Command", this problem accidental occur, in fact I
don't
need do any thing, it will be fixed.

I don't sure you can reproduce this problem, but it really puzzle me and
my colleague.

Please solve this problem,thanks!

  1. Yes,in my testcase, I had open a connetion, and loged in before using
    Execute Command keyword,usually,I will create 2 connetion,and record them session
    id,and when testcase need use it,then switch to conn.

  2. I running tests on Python.

  3. I work for NSN

Execute command is ignoring output after empty line when jython is used.

Originally submitted to Google Code by simo.ens... on 30 Oct 2008

What steps will reproduce the problem?

  1. Using SSHLibrary's Execute Command KW, run e.g. command "cat
    somefile.txt". somefile.txt contains empty line in first line, then some
    other lines. Execute test case using jybot.

What is the expected output? What do you see instead?
Expected output is the whole content of the text file. Now nothing is
returned because of empty line in the beginning.

What version of the product are you using? On what operating system?
SSHLibrary version 0.7. OS: Windows.

Please provide any additional information below.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.