Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: exec command Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
phil13
Groupie
Groupie
Avatar

Joined: December 19 2004
Location: France
Online Status: Offline
Posts: 60
Posted: May 25 2005 at 03:24 | IP Logged Quote phil13

Hi,

is there a way from a command line or an other application to send datas to powerhome ?

Something like that : EXEC "powerhome.exe %DATA1"

And how can i get it in powerhome ?

philippe
Back to Top View phil13's Profile Search for other posts by phil13
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: May 25 2005 at 08:07 | IP Logged Quote TonyNo

There are a few ways to get data into PH...

In my latest exersize, I used a batch file to ping some local machines and redirected the output to a text file. I then read the text file into PH and pull out info from it.

If your app supports Windows Messaging, PH can send and receive data using this.

The PHCommand util in the download section could also be used, depending.

Anyone else have other ideas?
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
phil13
Groupie
Groupie
Avatar

Joined: December 19 2004
Location: France
Online Status: Offline
Posts: 60
Posted: May 25 2005 at 09:28 | IP Logged Quote phil13

tony,

i've though about text file but what's append if powerhome want to read it and the other application want to write in it in the same time ?

Does windows manage this problem ?


Otherwise, the Phcommand utility seems to be a very good and powerfull idea. I've tried but i've a problem.

The utility documentation say need to have PBVM80.DLl, LIBJCC.DLL and PH32.DLL installed but on my computer i can't find pbvm80.dll but i've a pbvm90.dll ...

Does someone heve pbvm80.dll ?


Back to Top View phil13's Profile Search for other posts by phil13
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: May 25 2005 at 12:54 | IP Logged Quote TonyNo

Don't they come with phcommand? I have them in my phcommand folder. Maybe I copied them there from somewhere else?

I would send it to you, but I don't know if there are licensing issues. Dave should be able to assist here.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
phil13
Groupie
Groupie
Avatar

Joined: December 19 2004
Location: France
Online Status: Offline
Posts: 60
Posted: May 25 2005 at 13:25 | IP Logged Quote phil13

Tony,

it don't come with phcommand.zip.

After a little search it seems that :
- pbvm90.dll is for PowerBuilder 9.0
- pbvm80.dll is for PowerBuilder 8.0
Back to Top View phil13's Profile Search for other posts by phil13
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: June 01 2005 at 11:47 | IP Logged Quote dhoward

Phil,

The phcommand.zip in the download section is a little outdated. I would post the pbvm80.dll (and other PowerBuilder 8.0 runtime files) except that I don't have it loaded on my new development machine (old notebook crashed).

I will rework this utility to use the latest runtimes and post them when I have it done.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: June 10 2005 at 18:02 | IP Logged Quote dhoward

Check out the PowerHome Download page. At the bottom Ive added two new utilities for command line control.

The first is command line control using the PowerHome Windows Messaging interface. This program will allow you to execute a formula from the command line of the local PowerHome machine. Includes complete VB source code.

The second is a command line control utilizing the PowerHome Socket Server interface. Using the program will allow you to control PowerHome from the command line of the local machine AS WELL as any remote networked machine. Requires the socket server interface be enabled within PowerHome. Again, with complete VB source code.

One of these utilities should do the trick for you.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: June 10 2005 at 19:06 | IP Logged Quote TonyNo

Cool! Are these different from phcommand?
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: June 10 2005 at 19:17 | IP Logged Quote TonyNo

I just d/l'ed phsscmd_setup.exe and got this error...

Error 1324.The path ***IS_STRING_NOT_DEFINED***
contains an invalid character.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
krommetje
Super User
Super User
Avatar

Joined: December 29 2004
Location: Netherlands
Online Status: Offline
Posts: 695
Posted: June 12 2005 at 10:59 | IP Logged Quote krommetje

I've got the same problem here!

Peter
Back to Top View krommetje's Profile Search for other posts by krommetje Visit krommetje's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: June 12 2005 at 22:21 | IP Logged Quote dhoward

It was a bad build from InstallShield. I just rebuilt the install and uploaded it. Give it a try and let me know if this one is ok or not.

Tony,

Yep, a little different from the old PHCommand. The PHCommand was written in PowerBuilder necessitating the PowerBuilder runtimes. I believe it also used the webserver as the interface. Both of the new files are written in VB with source code (for learning purposes) and use the newer Windows Message and Socket Server interfaces.

Good luck,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
phil13
Groupie
Groupie
Avatar

Joined: December 19 2004
Location: France
Online Status: Offline
Posts: 60
Posted: June 13 2005 at 09:52 | IP Logged Quote phil13

Thanks dave.

Back to Top View phil13's Profile Search for other posts by phil13
 
phil13
Groupie
Groupie
Avatar

Joined: December 19 2004
Location: France
Online Status: Offline
Posts: 60
Posted: June 13 2005 at 11:35 | IP Logged Quote phil13

Dave,

i've tried to load VB projects and i had somes problems i think because i'm using Visual basic express 2005 beta 2.

http://lab.msdn.microsoft.com/express/vbasic/default.aspx

When i make the automatic update from vb6 to vb 2005 :

- i can't open phsscmd because problems of winsock licence

- i can open phwmcmd but i've upgrade issue in code :
(sorry for french but my vb is in french ...)

Friend Class PHWMCmd

     ....

     'UPGRADE_ISSUE: La déclaration d'un paramètre 'As Any' n'est pas prise en charge. Cliquez ici : 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm ?keyword="FAE78A8D-8978-4FD4-8208-5B7324A8F795"'

....

           'UPGRADE_WARNING: Impossible de résoudre la propriété par défaut de l'objet cds. Cliquez ici : 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm ?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
           iRet = SendMessage(hPwrHome, 74, 0, cds)

End Class
Back to Top View phil13's Profile Search for other posts by phil13
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: July 05 2005 at 11:20 | IP Logged Quote dhoward

Philippe,

Im not familiar with VB 2005 Express so not sure what upgrade issues you may have. However, the code is very simple so I'll just copy and paste it below.

The code for phwmcmd is:

****************************************
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long

Private Type COPYDATASTRUCT
    dwData As Long
    cbData As Long
    lpData As String
End Type

Dim hPwrHome As Long
Dim cds As COPYDATASTRUCT

Private Sub Form_Load()
    Dim sData As String
    Dim iRet As Long
    
    sData = Command()
    
    hPwrHome = FindWindow(vbNullString, " PowerHome ")
    
    If hPwrHome = 0 Then
        MsgBox ("PowerHome is not running")
    End If
    
    cds.dwData = 0
    cds.cbData = Len(sData)
    cds.lpData = sData

    iRet = SendMessage(hPwrHome, 74, 0, cds)
    
    End
End Sub
**********************************************

The code for phsscmd is:

*********************************************
Private Declare Function GetPrivateProfileString Lib "kernel32.dll" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
    
Dim sReturnData As String
Dim bConnect As Boolean

Sub form_load()
    Dim sRemoteHost As String
    Dim sRemotePort As String
    Dim sUserID As String
    Dim sPassword As String
    
    Dim sEncode As String
    Dim sAuthorize As String
    Dim sContentLength As String
    
    Dim sFormula As String
    
    Dim tStart As Date
    Dim tEnd As Date
    
    sFormula = Command()
    
    sRemoteHost = Space(256)
    sRemotePort = Space(256)
    sUserID = Space(256)
    sPassword = Space(256)
    
    sRemoteHost = Left(sRemoteHost, GetPrivateProfileString("settings", "remotehost", "127.0.0.1", sRemoteHost, Len(sRemoteHost), ".\phsscmd.ini"))
    sRemotePort = Left(sRemotePort, GetPrivateProfileString("settings", "remoteport", "8500", sRemotePort, Len(sRemotePort), ".\phsscmd.ini"))
    sUserID = Left(sUserID, GetPrivateProfileString("settings", "userid", "yourname", sUserID, Len(sUserID), ".\phsscmd.ini"))
    sPassword = Left(sPassword, GetPrivateProfileString("settings", "password", "yourpassword", sPassword, Len(sPassword), ".\phsscmd.ini"))
    
    Winsock1.RemoteHost = sRemoteHost
    Winsock1.RemotePort = CLng(sRemotePort)

    bConnect = False

    Winsock1.Connect

    tStart = Now
    Do
        tEnd = Now
        DoEvents
    Loop While bConnect = False And DateDiff("s", tStart, tEnd) < 10
    
    If bConnect = False Then
        Winsock1.Close
        End
    End If
    
    sAuthorize = "Authorization: Basic " + base64encode(sUserID + ":" + sPassword)
    
    sContentLength = "Content-Length: " + CStr(Len(sFormula))
    
    sReturnData = ""
    
    Winsock1.SendData ("FORMULA" + vbCrLf + sAuthorize + vbCrLf + sContentLength + vbCrLf + vbCrLf + sFormula)
    
    tStart = Now
    Do
        tEnd = Now
        DoEvents
    Loop While bConnect = True And DateDiff("s", tStart, tEnd) < 20
    
    If bConnect = True Then
        Winsock1.Close
        End
    End If
    
    Winsock1.Close
    
    End
End Sub

Sub winsock1_DataArrival(ByVal bytestotal As Long)
    Dim sTemp As String
    
    Winsock1.GetData (sTemp)
    sReturnData = sReturnData + sTemp
End Sub

Sub winsock1_Connect()
    bConnect = True
End Sub

Sub winsock1_Close()
    bConnect = False
End Sub

Function base64encode(sData As String)
    Const base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456 789+/"
    Dim lBlock As Long
    Dim iCount As Integer
    Dim iLen As Integer
    Dim sTail As String
    Dim sEncode As String
    
    iLen = Len(sData)
    iCount = 1
    
    Do While iCount <= iLen
        lBlock = Asc(Mid(sData, iCount, 1)) * 65536
        iCount = iCount + 1
        If iCount <= iLen Then
             lBlock = lBlock + Asc(Mid(sData, iCount, 1)) * 256
             iCount = iCount + 1
             If iCount <= iLen Then
                lBlock = lBlock + Asc(Mid(sData, iCount, 1))
                iCount = iCount + 1
                sTail = ""
             Else
                sTail = "="
             End If
        Else
             sTail = "=="
        End If
       
        sEncode = sEncode + Mid(base64, (lBlock And &HFC0000) / 262144 + 1, 1)
        sEncode = sEncode + Mid(base64, (lBlock And &H3F000) / 4096 + 1, 1)
        If sTail <> "==" Then
             sEncode = sEncode + Mid(base64, (lBlock And &HFC0) / 64 + 1, 1)
             If sTail <> "=" Then sEncode = sEncode + Mid(base64, (lBlock And &H3F) + 1, 1)
        End If
       
        sEncode = sEncode + sTail
    Loop
    
    base64encode = sEncode
End Function
************************************************

As far as the Winsock Control licensing issue....Im not sure if this control is included with VB Express so that may be the issue. You can however see the events that Ive coded for the Winsock Control and you may be able to create the project from scratch if importing is a problem.

Hope this helps,

Dave.

Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum