Need suggestion on how to connect to remote UNIX system and run some system commands like ls or ls -l and capture the output displayed to a flat file. Can anyone please advice or give some examples on how can this be done?
I am running cloverETL designer on Windows XP…
Dear Sureshsbhatia,
You need to download and install WinSCP application.
After that, you need a script which will be executed by CloverETL.
Suppose you will install your WinSCP into C:/Program Files/WinSCP folder.
There is a WinSCP.com command line tool in it.
You need to create a graph consisting of two SystemExecutes.
The first one will execute a script that will:
connect to the remote computer, execute the specified command, redirect its output to a file, download the file into your local working directory, and terminate the session.
This script will look like this:
open scp://myuser:mypassword@myhostname
call ls -l > listRemote.txt
get listRemote.txt
exit
After that you will have the listRemote.txt file in your C:/Program Files/WinSCP folder. You want to copy or move it to another destination. This will be executed in the second phase (phase 1) with another SystemExecute.
The whole graph will be as follows:
<?xml version="1.0" encoding="UTF-8"?>
<Graph author="cloveruser" created="Thu Sep 30 09:37:35 CEST 2010" guiVersion="3.0.1.hudson182" id="1285833516600" licenseType="Evaluation Devel" modified="Fri Oct 01 13:18:19 CEST 2010" modifiedBy="cloveruser" name="remote" revision="1.176">
<Global>
<Property id="GraphParameter1" name="destination" value="D:"/>
<Property id="GraphParameter2" name="file" value="listRemote.txt"/>
<Property id="GraphParameter13" name="scriptPATH" value="D:/workspace_hudson_182/forum/data-in"/>
<Property id="GraphParameter0" name="working" value="C:/Program Files/WinSCP"/>
<Property fileURL="workspace.prm" id="GraphParameter3"/>
<Dictionary/>
</Global>
<Phase number="0">
<Node deleteBatch="false" enabled="enabled" guiHeight="0" guiName="SystemExecute" guiWidth="0" guiX="286" guiY="154" id="SYS_EXECUTE0" interpreter="${}" type="SYS_EXECUTE" workingDirectory="${working}">
<attr name="command"><![CDATA[WinSCP.com /script=${scriptPATH}/myscript.bat
]]></attr>
</Node>
</Phase>
<Phase number="1">
<Node deleteBatch="true" enabled="enabled" guiHeight="0" guiName="SystemExecute" guiWidth="0" guiX="290" guiY="275" id="SYS_EXECUTE1" interpreter="${}" type="SYS_EXECUTE" workingDirectory="${working}">
<attr name="command"><![CDATA[copy ${file} ${destination}]]></attr>
</Node>
</Phase>
</Graph>
You need to choose the values of “destination”, “file”, “scriptPATH” parameters. The “file” is the same as that specified in the script.
The “working” value is the folder where WinSCP is installed.
Best regards,
You can also use only one SystemExecute with another script (maybe this is a better solution):
open scp://myusername:mypassword@myhostname
call ls -l
exit
And the graph will be as follows:
<?xml version="1.0" encoding="UTF-8"?>
<Graph author="cloveruser" created="Thu Sep 30 09:37:35 CEST 2010" guiVersion="3.0.1.hudson182" id="1285833516600" licenseType="Evaluation Devel" modified="Fri Oct 01 13:33:08 CEST 2010" modifiedBy="cloveruser" name="remote" revision="1.179">
<Global>
<Property id="GraphParameter13" name="scriptPATH" value="D:/workspace_hudson_182/forum/data-in"/>
<Property id="GraphParameter0" name="working" value="C:/Program Files/WinSCP"/>
<Property fileURL="workspace.prm" id="GraphParameter3"/>
<Dictionary/>
</Global>
<Phase number="0">
<Node deleteBatch="false" enabled="enabled" guiHeight="0" guiName="SystemExecute" guiWidth="0" guiX="286" guiY="154" id="SYS_EXECUTE0" interpreter="${}" outputFile="${DATAOUT_DIR}/log.txt" type="SYS_EXECUTE" workingDirectory="${working}">
<attr name="command"><![CDATA[WinSCP.com /script=${scriptPATH}/myscript2.bat
]]></attr>
</Node>
</Phase>
</Graph>
The output will be saved in the ${DATAOUT_DIR}/log.txt file.
Regards,
Thanks Tomas. I will try this out.