Start complex UNIX-Script with wodSSH - WeOnlyDo Discussion board

Start complex UNIX-Script with wodSSH (wodSSH / wodSSH.NET)

by Zitterbacke, Tuesday, March 28, 2006, 08:24 (6613 days ago)

Hello,

I have a problem with great complex UNIX-Scripts on a LINUX-Server!

wodSSH (2.3.4 Version) in VB6.
With Standard-UNIX-Commandos (example ls -l ), I have no problem's.

wodssh start in a function, with the WaitFor Method, because I will waiting for the prompt:
[code]
Public Function fncWartenEndeSSH(Hostname As String, Login As String, _
Passwort As String, UNIX_Kommando As String) As Variant

On Error GoTo Fehlerauswertung

frmTarn.wodSSH1.Disconnect
frmTarn.wodSSH1.Hostname = Hostname
frmTarn.wodSSH1.Login = Login
frmTarn.wodSSH1.Password = Passwort
frmTarn.wodSSH1.Blocking = True
frmTarn.wodSSH1.StripANSI = True
frmTarn.wodSSH1.Protocol = SSHAuto
frmTarn.wodSSH1.Connect

frmTarn.wodSSH1.WaitFor (Login & @ & LCase(Hostname))

If frmTarn.wodSSH1.DataReady > 0 Then frmTarn.wodSSH1.Receive

fncWartenEndeSSH = (frmTarn.wodSSH1.Execute(UNIX_Kommando & vbLf, Login & @ & LCase(Hostname), 10))

frmTarn.wodSSH1.Disconnect

frmTarn.wodSSH1.ShowStdErrorMessages = True
Exit Function

Fehlerauswertung:
frmTarn.wodSSH1.ShowStdErrorMessages = False
End Function

strUNIX_KOMMANDO = UNIX-Script
Debug.Print strUNIX_KOMMANDO
vntERGEBNIS = fncWartenEndeSSH(SERVER_LNX, SERVER_LNX_LOGIN, SERVER_LNX_PASSWORT, strUNIX_KOMMANDO)

[/code]

The complex UNIX-Script start other scripts and C-programs on Server.
I became a prompt to early in VB6, because UNIX-script is still running. The script ist not finished.
Controlling with 'ps -ef' or 'top' on putty.

Can you help me?

Regards from Bavaria!

Re: Start complex UNIX-Script with wodSSH

by wodDrazen, Tuesday, March 28, 2006, 09:55 (6613 days ago) @ Zitterbacke

Hi,


Maybe you have problem with prompt that you expecting to receive from server, you can try to change lines:

frmTarn.wodSSH1.WaitFor (Login & @ & LCase(Hostname))
fncWartenEndeSSH = (frmTarn.wodSSH1.Execute(UNIX_Kommando & vbLf, Login & @ & LCase(Hostname), 10))

with

frmTarn.wodSSH1.WaitFor( regex:[$ #>] $ )
fncWartenEndeSSH = (frmTarn.wodSSH1.Execute( UNIX_Kommando & vbLf, regex:[$ #>] $ , 10))

Regular expression ( $ #>] ) means it will accept any of those chars ($, ,#,>) if they appear at the end of the line.
This includes 99.9 of most UNIX command prompts (including root account).

Let us know how it goes.


Regards,
Drazen

Re: Start complex UNIX-Script with wodSSH

by Zitterbacke, Tuesday, March 28, 2006, 10:44 (6613 days ago) @ wodDrazen

Hello,

with yours modification, the Script don't start. Also with
'ls -l'.

The Prompt of our Server is definitive:

[color=#abcdef]dtk25@blvamuc-lnxr3402:>[/color]

dtk25 = Login
blvamuc-lnxr3402 = Servername

With my Code, I can start synchron UNIX-Kommandos, but not complex
UNIX-Scripts.

[code]
frmTarn.wodSSH1.WaitFor (Login & @ & LCase(Hostname))
fncWartenEndeSSH = (frmTarn.wodSSH1.Execute(UNIX_Kommando & vbLf, Login & @ & LCase(Hostname), 10))
[/code]

Regards
F.S.

Re: Start complex UNIX-Script with wodSSH

by wodDrazen, Tuesday, March 28, 2006, 11:19 (6613 days ago) @ Zitterbacke

Hi,


I have one question, did you mean to run Script Command in UNIX Server?

Here is how I did it in VB6:
----------------------------
Dim WithEvents ssh1 As wodSSHCom
Set ssh1 = New wodSSHCom
ssh1.HostName = Hostname
ssh1.Blocking = True
ssh1.StripANSI = True
ssh1.Login = login
ssh1.Password = password
ssh1.Protocol = SSHAuto
ssh1.Connect

ssh1.WaitFor ( regex:[$ #>] $ )
If ssh1.DataReady > 0 Then ssh1.Receive
Debug.Print ssh1.Execute( script & vbLf, regex:[$ #>] $ )

ssh1.Disconnect
--------------------------------

And here is what I received from my server:
--------------------------------------
script
Script started, file is typescript
kreso1@knjiga:~
---------------------------------------

If this is what you what to do, can we connect to your server and try to duplicate your problem?
Or you have problem with something other then this?


Regards,
Drazen

Re: Start complex UNIX-Script with wodSSH

by wodSupport, Tuesday, March 28, 2006, 11:54 (6613 days ago) @ wodDrazen

Zitterbacke,

hi. I'm not sure why there is any difference between simple 'ls -al' and some large 'unix-script' commands, since from client's perspective these are the same.

Even more, in our tests, we can't (obviously) test the same script because we don't have it. We can only test with something available on our UNIX environment, such as that popular 'ls -al' :)

Anyway, can we somehow duplicate this so we don't blindly attempt to figure out what could be wrong? Can you provide us with your hostname/login/password so we can connect there and see what's going on? If you can, please don't post that info here, send it to techsupport@weonlydo.com


BTW a question: how do you know script wasn't executed? What happened after you called Execute method with that script name as argument?

Greetings to Bavaria!

Kreso

Re: Start complex UNIX-Script with wodSSH

by Zitterbacke, Tuesday, March 28, 2006, 12:08 (6613 days ago) @ wodSupport

Hello,

yes, I will start a UNIX-Script synchron with wodSSH (in Vb6) on an UNIX-Server(LINUX).
Sorry , our UNIX-Server is behind a Firewall. I am not the System-Admin for this. I can't change the permission.


Here a Example (for cartography) of the UNIX-Scripts:

The complex UNIX-Script with other UNIX-Scripts and C-programs.
Sorry, with german commentar!

[code]
#!/bin/bash

#===========================================================================
#
# Rasterisierungen End-Aufbereitung der Karte und der Legende
#
#
#===========================================================================

#--- Notwendige Aenderungen fuer plot25.exe ---
cd $HOME
. .profile
cd $HOME/DTK25/TAB
#--- F. Schneller ---

if [ $# -ne 1 ]
then
echo Falscher Prozeduraufruf (Falsche Anzahl ($#) der Argumente)
echo Aufruf: tu_map_leg Blattnummer
exit
fi

#---
# Nur Auskommentiert, falls doch einmal ein anderer Server verwendet wird! F.S.
#---
# SERVER_tk25=`pg server_tk25.txt`
# LOGIN_tk25=`pg login_tk25.txt`
# PASS_tk25=`pg pass_tk25.txt`
# DIR_tk25=`pg dir_tk25.txt`
#---

echo =============================================================
echo = Start Berechnung Karte und Legende Blatt $1 =
echo =============================================================


if [ ! -d $HOME/DTK25/$1 ]
then
mkdir $HOME/DTK25/$1
fi

cd $HOME/DTK25/$1

############# Aufrufprozeduren holen ################################

cp $HOME/DTK25/TAB/* .
chmod 777 tu*


#============================================================================
# Sonderfaelle: Ueberkartierungen
#============================================================================

ANZ_SPA_LEG=8000
ANZ_ZEI_LEG=17000
AUFL=320
ANZ_SPA=18000
ANZ_ZEI=17000

if [ $1 = 6643 ]
then
(( ANZ_SPA = ANZ_SPA + 9693*$AUFL/1000 ))

elif [ $1 = 7248 ]
then
(( ANZ_SPA = ANZ_SPA + 1000*$AUFL/1000 ))

elif [ $1 = 7348 ]
then
(( ANZ_SPA = ANZ_SPA + 1656*$AUFL/1000 ))

elif [ $1 = 7645 ]
then
(( ANZ_ZEI = ANZ_ZEI + 3703*$AUFL/1000 ))

elif [ $1 = 7842 ]
then
(( ANZ_SPA = ANZ_SPA + 10677*$AUFL/1000 ))

elif [ $1 = 7942 ]
then
(( ANZ_SPA = ANZ_SPA + 9362*$AUFL/1000 ))

elif [ $1 = 8143 ]
then
(( ANZ_SPA = ANZ_SPA + 1952*$AUFL/1000 ))

elif [ $1 = 8336 ]
then
(( ANZ_ZEI = ANZ_ZEI + 8097*$AUFL/1000 ))

elif [ $1 = 8337 ]
then
(( ANZ_ZEI = ANZ_ZEI + 8168*$AUFL/1000 ))

elif [ $1 = 8344 ]
then
(( ANZ_ZEI = ANZ_ZEI + 12500*$AUFL/1000 ))

elif [ $1 = 8526 ]
then
(( ANZ_SPA = ANZ_SPA + 3380*$AUFL/1000 ))

elif [ $1 = 8531 ]
then
(( ANZ_ZEI = ANZ_ZEI + 3000*$AUFL/1000 ))

elif [ $1 = 8532 ]
then
(( ANZ_ZEI = ANZ_ZEI + 2820*$AUFL/1000 ))

elif [ $1 = 8533 ]
then
(( ANZ_ZEI = ANZ_ZEI + 8168*$AUFL/1000 ))

elif [ $1 = 8543 ]
then
(( ANZ_ZEI = ANZ_ZEI ))

fi

#=============================================================================
# Kartenteil berechnen
#=============================================================================

echo Start Berechnung Kartenteil Blatt $1 mit ...
echo ........ tu_end_DTK25 $1 $ANZ_SPA $ANZ_ZEI $AUFL

tu_end_DTK25 $1 $ANZ_SPA $ANZ_ZEI $AUFL | tee tu_end_DTK25.prot 1>/dev/null

#=============================================================================
# Legendenteil berechnen
#=============================================================================

echo Start Berechnung Legendenteil Blatt $1 mit ...
echo ......... tu_end_LEG25 $1 $ANZ_SPA_LEG $ANZ_ZEI_LEG $AUFL

tu_end_LEG25 $1 $ANZ_SPA_LEG $ANZ_ZEI_LEG $AUFL | tee tu_end_LEG25.prot 1>/dev/null

#=============================================================================
# Kartenteil und Legendenteil zusammenfassen
#======================================================================

Re: Start complex UNIX-Script with wodSSH

by wodSupport, Tuesday, March 28, 2006, 12:40 (6613 days ago) @ Zitterbacke

I am not sure this helps us. Since we cannot connect, there's one thing I'd like to suggest.

Can you create new script on your UNIX, so that it contains only these lines:

[code]
#!/bin/bash
/bin/ls -al
[/code]

Can you start that using wodSSH? Does it work?
If this works, then paste in that script part by part by part of your old one until it fails to work.

Do you see the idea? Let's isolate if problem is with your specific script (and if it is, where exactly...) or with scripts in general.

Kreso

Re: Start complex UNIX-Script with wodSSH

by Zitterbacke, Thursday, March 30, 2006, 07:50 (6611 days ago) @ wodSupport

Hello Kreso, hello Alan!

Bingo!!!!!!!

Yes, it is a timeout-Problem!

I change the timeout to zero.
With this modification, I can start long running UNIX-Scripts.
Here is my new Code:

[code]
frmTarn.wodSSH1.Disconnect
frmTarn.wodSSH1.Hostname = Hostname
frmTarn.wodSSH1.Login = Login
frmTarn.wodSSH1.Password = Passwort
frmTarn.wodSSH1.Timeout = [color=#abcdef]0[/color]
frmTarn.wodSSH1.Blocking = True
frmTarn.wodSSH1.StripANSI = True
frmTarn.wodSSH1.Protocol = SSHAuto
frmTarn.wodSSH1.Connect

frmTarn.wodSSH1.WaitFor Login & @ & LCase(Hostname), [color=#abcdef]0[/color] ' Hernehmen des Gesamt-Prompt

If frmTarn.wodSSH1.DataReady > 0 Then frmTarn.wodSSH1.Receive

fncWartenEndeSSH = (frmTarn.wodSSH1.Execute(UNIX_Kommando & vbLf, Login & @ & LCase(Hostname), [color=#abcdef]0[/color] ))

[/code]

Thank you for good support (E-Mail, Forum)

Regards from Munich!
F.S.