How to run python function in Unix server using Excel VBA? -
I want to automate the steps below using the Excel VBA / VB script.
To transfer a file from a local machine to 'testfile' to a directory, using Unix Server Winscp (a dragon script in the directory 'connector.py
Step 2: Open Pulse
- Destination Host Name: example.ash.pwj.com
- Port: 22
- Connection type: SSH
- Using login credentials.
Step 3: Call the Python script in the directory. python connector.py testFile example2.ash.pwj.com 123
Example: Here's my code:. I use Excel VBA / VBScript to transfer the WinSCP file to Putty and call the Python script.
Set = CreateObject ("WScript.Shell") sh.Run "pscp -pw yyyy C: \ Users \ abc \ testfile xxx@example.ash.pwj.com: / home / Test / dir ", 0, is true sh.Run" plink.exe -pw yyyy xxx @ example.ash.pwj.com dragon / home / test / dials / connector / testFile example 2.ash.pwj.com 514 " , 0, true
You can open yourself outside of:
set sh = CreateObject ("WScript.Shell") sh.Run "pscp -pw yyyy c: \ testfile xxx@example.com: / some / dir / ", 0, this is true sh.Run" -pw yyyy xxx@example.com dragon / some plink /dir/connector.py arg1 arg2 arg3 ", 0, true
note That's the path to add a proper quote Shykta includes spaces.
If your destination path is the destination directory only without the filename, specify the path path name. In this way you will get an error when the destination directory does not exist otherwise the pscp file user@example.com: / some / dir
will be able to change that file to / some / dir / file
Instead, / some / dir
can be created when a subdirectory is not dir
in / some
.
In addition, you need to make sure that you pass the correct path to your Python script. When you copy the file to / home / test / dir /
, you must either change it before calling the Python script in that directory, or specify the file name with its full path Do:
sh.Run "plink.exe -pw yyyy xxx@example.ash.pwj.com dragon /home/test/dir/connector.py/ home / test / dir / testfile Running Python Script from example2.ash.pwj.com 514 ", 0, true
/ home / test / dir
does not automatically create the current working directory for that directory is.
Comments
Post a Comment