Wednesday, 15 August 2012

ssh - Paramiko: Executing a perl script within a shell script -


Hi I have the shell script inside which a Perl script is embedded.

cat chkLog.sh

  LOGFILE = 'counterchange $ 1' echo "# Action 15: Check Log" | T-IA $ LagFill Pearl & lt; & Lt; '__THERE__' | T $ $ LOGFILE print ("Hello word \ n"); Some more complex Perl code. . __THERE__ resonance "#EndAct" | LogFile $ -ia T  

Actually I'm using the here-docs concept to execute a Perl code. Now if I execute the above script directly on the server then I get the desired out. But when I send it through Parmico, the Pearl part is completely ignored. And the output is:

Paramiko through output:

  # 1515: Check log #EndAct " 

Paramiko Script:

<> & gt; hostname = '192.168.122.1'> gt; & gt; user name = 'can be' & gt; & gt; Gt; & gt; password = '*******' & gt; & gt; setupcommand = "/ user / may / click_demo_test / chkLog.sh"> gt;> resultloc = "/ User / SPM / click_demo_test / setuplog / chkLog.sh"> gt; & gt; execomand = setupcommand + 'resultloc> gt;' & gt; & gt; ssh = paramiko.SSHClient () & gt; & Gt; & gt; ssh.set_missing_host_key_policy (paramiko.autoAddPolicy ()) & gt; & gt; ssh.connect (host name, user Name = username, password = password)> Channel = ssh.get_transport (). Open_session () >> gt;> channel.exec_command (execomand)>>>>>> Except_status_ready (): time.sleep (1) & gt; stdout = channel.makefile ("rb") & gt; & gt; & Gt; Print stdout.readlines ()

Shell must be changed to complete the Pearl As a busy task, I have several scripts.

Since you are not seeing a return value, are you sure that the shell script does not allow the Perl command Have not tried to run and fail? Would I recommend checking the return code in shell script $? And perhaps put a complete path to Pearl Interpreter to eliminate any environmental issues.


No comments:

Post a Comment