cmdssh
Execute commands on local machine and on remote machine via ssh, and a wrapper for paramikos scp.
shell command
Wrapper around subprocess.call with shell=True
shell(cmd)
Background Unix command running
Runs a blocking unix command and returns the result
cmd_run(cmd, pr=False, streamoutput=True, returnoutput=True, cwd=None, prefix=None)
# example
cmd_run('date "+%Y-%m-%d% %H:%M"', pr=False, streamoutput=False, returnoutput=True)
# more params
call_command(command, cmdfolder=os.getcwd(), verbose=False, streamoutput=True,\
returnoutput=False, prefix=None, ret_and_code=False)
Parameters:
command: unix command
cmdfolder=os.getcwd() -> working folder command
verbose=False -> prints the command
streamoutput=True -> prints output to stdout (keeps buffering)
returnoutput=False -> return the buffered output
prefix=None -> string to place before streaming output
ret_and_code=False -> return exit code also (code, val)
Variant background unix command
Common usecase scenario, run a command and get the result, possibly print to the console using an optional filter.
# example filter:
def onlyerrors(data):
if "ERROR" in data:
return data
cmd_exec(cmd, cmdtoprint=None, display=True, myfilter=onlyerrors)
cmdtoprint: unix command
display: print to console
myfilter: function used to print
SSH: run command on remote machine
Uses ssh and key authentication to logon to a remote ssh server and execute a command there.
def remote_cmd(server, cmd, username=None, timeout=60, keypath=None):
#example
remote_cmd("localhost", "rm -Rf ~/Desktop/foobar")
Parameters:
server: ip or domain name of server
cmd: unix command to execute
username: username used to login
timeout: try time to connect to server
keypath: path to the public key of username
tuplebased interface:
remote_cmd_map(servercmd)
servercmd: tuple with ( server, cmd, username, keypath )
SSH: Secure Copy Protocol
scp_get(server, fp1, fp2, username=None, keypath=None)
scp_put(server, fp1, fp2, username=None, keypath=None)
Parameters:
server: ip or domain name of server
fp1: source filepath
fp2: target filepath
username: username used to login
keypath: path to the public key of username
SSH: Shell
Invoke a shell on a machine
invoke_shell(server, username, keypath)
Parameters:
server: ip or domain name of server
username: username used to login
keypath: path to the public key of username
Download file
Wrapper around the requests library. Downloads a file with a progress bar.
download(url, mypath):
parameters:
url: url to download
mypath: filepath where to create the downloaded file
example output:
download: http://download.thinkbroadband.com/5MB.zip
00:00:02|███████████████████████ | 3.7Mi/5.0Mi
Metadata
Release files for cmdssh 50
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cmdssh-50.tar.gz | 9.7 kB | Without provenance | Details for cmdssh-50.tar.gz |
Release files / cmdssh-50.tar.gz
| Download URL | cmdssh-50.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2581235500a97fddd6e655554703443702a6495aad0e554e81807ca80814c4da
|
|
BLAKE2b-256 checksum How to use checksums |
bc90819a145445e0e08db22dc4db1daefca95ae719a474a28f09a2bbfbbd22fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for cmdssh 50
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.