2015-06-17 2 views
-1

Как запускать внешние исполняемые файлы с использованием скриптов python? Я хотел бы запустить putty.exe, который установлен в определенном каталоге, скажем, диск C в папке с именем «putty». Выполняю скрипт Test.py из командной строки D: \ python> Test.py.Запуск внешних исполняемых файлов с использованием сценариев python

Я выполняю следующие действия, которые не работают import os; печать os.system ('putty.exe')

+1

You может использовать подпроцесс и передать ip с помощью str.format, вы также можете добавить путь к замазке к вашему PATH в переменных среды, а затем просто вызвать putty будет работать –

+1

Вы можете использовать подпроцесс, вы также можете добавить путь к putty вашему PATH в ваших переменных окружения, то просто вызов шпатлевки будет работать , Вы также можете найти это полезное http://superuser.com/questions/515601/how-to-run-a-command-file-in-putty-using-automatic-login-in-a-command-prompt –

ответ

-1

Вы можете попробовать это:

os.system ('C:/putty/putty.exe') 
+0

Но, как я могу автоматизировать ввод ip-адреса в поле адреса в этом исполняемом файле putty? – Razor

1

Используйте параметр командной строки для загрузки сохраненной сессии с правой IP-адрес

The `-load' option causes PuTTY to load configuration details out 
    of a saved session. If these details include a host name, then this 
    option is all you need to make PuTTY start a session. 

    You need double quotes around the session name if it contains 
    spaces. 

    If you want to create a Windows shortcut to start a PuTTY saved 
    session, this is the option you should use: your shortcut should 
    call something like 

    d:\path\to\putty.exe -load "my session" 

    (Note that PuTTY itself supports an alternative form of this option, 
    for backwards compatibility. If you execute `putty @sessionname' it 
    will have the same effect as `putty -load "sessionname"'. With the 
    `@' form, no double quotes are required, and the `@' sign must be 
    the very first thing on the command line. This form of the option is 
    deprecated.) 
Смежные вопросы