I would like to achieve the following things:

Given file contains a job list which I need to execute one by one in a remote server using SSH APIs and store results.

When I try to call the following command directly on remote server using putty it executes successfully but when I try to execute it through python SSH programming it says cant find autosys.ksh.

autosys.ksh autorep -J JOB_NAME

Any ideas? Please help. Thanks in advance.

有帮助吗?

解决方案

Fabric is a good bet. From the home page,

Fabric is a Python (2.5 or higher) library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks.

A quick example,

>>> from fabric.api import run, env, cd, settings, hide, show
>>> env.host_string='xxx.xxx.com'
>>> env.user='user'
>>> env.password='password'
>>> run('ls -lart')

其他提示

After reading your comment on the first answer, you might want to create a bash script with bash path as the interpreter line and then the autosys commands.

This will create a bash shell and run the commands from the script in the shell.

Again, if you are using autosys commands in the shell you better set autosys environment up for the user before running any autosys commands.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top