Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Other Machines Online Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: May 18 2005 at 20:31 | IP Logged Quote TonyNo

Any ideas for being able to tell if other machines on the local network are online? Maybe a ph_ping command?

How is that plugin interface coming?
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

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

Hmmm...A ph_ping would be a good idea. I'll have to do a little research.

Havent gotten a chance to do much work on the plug-in interface yet. Have been sidetracked on integrating a real source code editor into PowerHome. I think it will be a big hit...especially for the VBScripters. But also for anybody who works with formulas since I plan on extending it to the formula builder and the SQL screens.

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: May 19 2005 at 22:11 | IP Logged Quote TonyNo

I had the bright idea that I could just do a ph_run( "ping.exe xxx -n 1 > ping.txt") and then scrape the txt file, but it seems to not like something.
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: May 20 2005 at 05:39 | IP Logged Quote krommetje

TonyNo wrote:
I had the bright idea that I could just do a ph_run( "ping.exe xxx -n 1 > ping.txt") and then scrape the txt file, but it seems to not like something.


I have tried it over here and it seems that the file ping.txt is not created however the formula results to a 1
Even when I give the full path to ping.txt the file is not created... What happens if you do this in VB and let it run by PH and afterwards import it with ph_readfile(... ?

short update: When I run the same command on my laptop without PH then the file IS created...

Peter



Edited by krommetje
Back to Top View krommetje's Profile Search for other posts by krommetje Visit krommetje's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

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

Yes, my initial testing outside of PH worked fine.

I think the reason PH is not running it correctly is somewhere in the arguments used and not passed.
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: May 20 2005 at 12:46 | IP Logged Quote krommetje

TonyNo wrote:
Yes, my initial testing outside of PH worked fine. I think the reason PH is not running it correctly is somewhere in the arguments used and not passed.


I tried it with:

..>>ping.txt" ) and again: outside PH it works but as soon as PH is involved.... a code 1 is given but the file is not created

Also I tried:
ph_run ( "command.exe ping.exe x.x.x.x -n 1 > ping.txt" )
(my server runs on win98) and that gave an error -1

the other thing i have tried is:
ph_run ( "c:\windows\ping.exe x.x.x.x -n 1 > d:\ping.txt" ) Again a code 1 is given and the file is not created

Now with a batch-file:
in the batch file I've put ping x.x.x.x -n 1 > ping.txt
The batch-file is named pingx.bat....
in the formula I've put: ph_run( "pingx.bat" ) and MAN WHAT A BARNBURNER: IT WORKS!!!!

Hopefully it works for you too.......


Peter

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

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

I figured that would. Now I need to see if I can pass the machine name to the batch file so there is only one needed.
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: May 20 2005 at 16:15 | IP Logged Quote krommetje

TonyNo wrote:
I figured that would. Now I need to see if I can pass the machine name to the batch file so there is only one needed.


well, that shouldn't be too difficult, just replace the IP-address or the machinename inside the batch-file with a %1 and call the batchfile with the machinename... this should do it:

pingx.bat <machinename>

(if I remember correctly from my days I programmed in 4dos)

Goodluck,
Peter

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

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: May 20 2005 at 17:52 | IP Logged Quote TonyNo

Oh, sure! What I meant was that I hope PH won't choke on passing the machine name!
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: May 20 2005 at 21:29 | IP Logged Quote TonyNo

Argh! It doesn't work! It does not like something!

I've tried both ph_run and Launch App.

Edited by TonyNo
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: May 21 2005 at 02:12 | IP Logged Quote krommetje

TonyNo wrote:
Argh! It doesn't work! It does not like something! I've tried both ph_run and Launch App.


how many machines do you have to ping? If there are more than 1 PC's to ping I still would create a batchfile for every PC seperate because then you can name ping.txt e.g. pinglivingroom.txt and for your other pinghallway.txt
What is the advantage IMHO: better overview instead of just having all pingresults into one textfile... If anything is wrong during programming then looking for the error is faster because you are just working on one "ping"

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

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

Even running (ph_run) a batch file with the machine name in it does not create the file for me! The batch file works from a command line.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: May 23 2005 at 17:00 | IP Logged Quote dhoward

Tony,

Found the solution to your problem...no batch files, etc.

Try:

ph_run('cmd.exe /c ping -n 1 x.x.x.x > c:\ping.txt')

The trick is in the "/c". This should create the file for you.

Also, the next version has a ph_ping function. It was a pain in the butt, yet once again, Dave the Great conquered all .

Hope this helps,

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: May 23 2005 at 17:59 | IP Logged Quote TonyNo

Hehe! You are now DTG! No more, "you da man"!

I'll try this tonight.

What does ph_ping return?
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: May 23 2005 at 20:02 | IP Logged Quote TonyNo

OK! You can't redirect the file to a path that includes spaces.

This is what I needed to do to get it to work with a variable containing the machine name/address...

Set System [TEMP1] "kiosk"
Set System [TEMP2] "cmd.exe /c ping.exe -n 1 " + "[TEMP1]" + "> c:\ping.txt"
Formula ph_run( "[TEMP2]" )


More later!
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: May 23 2005 at 21:12 | IP Logged Quote TonyNo

Can someone check to see if ph_macroparmret() actually returns the proper LOCAL1 value in the latest beta? I am passing a value into LOCAL1, and changing it in my macro, but it does not return the updated value (it returns what I sent).

Set System [LOCAL1] ph_macroparmret( "PING", "kiosk", "", "", "", "" )

Thanks!
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: May 23 2005 at 23:50 | IP Logged Quote dhoward

Tony,

ph_ping will return the number of milliseconds it took for the ping to be returned. So a value of 0 (really quick) or above indicates the machine is available. Negative values indicate an error. I don't have the list in front of me, but it's similar to - 1 indicates a socket error, - 2 indicates an invalid address and -11000 and above return the standard ping error messages.

You can redirect to a path with spaces by enclosing the path within double quotes (DOS only understands double quotes) and the whole ph_run command within single quotes (PowerHome can use either / or) like:

ph_run('cmd.exe /c ping -n 1 x.x.x.x > "c:\program files\powerhome\ping.txt"')

The above worked for me.

I also checked the ph_macroparmret function and the output of it correctly returned what was in the [LOCAL1] variable of the called function. If you post the functions, I could probably pinpoint it for you.

Good Luck ,

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: May 24 2005 at 00:03 | IP Logged Quote TonyNo

Cool, DTG!

Here is my macro...

insert into macroheader values ('PING','PING MACHINES',0,0,1);
insert into macrodetail values ('PING',1,15,'[LOCAL2]',NULL,'"cmd.exe /c ping.exe -n 1 "+ "[LOCAL1]" + " > c:\ping.txt"',0);
insert into macrodetail values ('PING',2,38,'',0,'ph_run( "[LOCAL2]" )',0);
insert into macrodetail values ('PING',3,31,'',NULL,'2',0);
insert into macrodetail values ('PING',4,15,'[LOCAL3]',NULL,'ph_readfile( "c:\ping.txt")',0);
insert into macrodetail values ('PING',5,15,'[LOCAL1]',NULL,'if( pos( "[LOCAL3]", "Reply") <> 0, "Online", "Offline" )',0);
insert into macrodetail values ('PING',6,24,'No TTS',1,'"[LOCAL1]" + " = " + "[LOCAL4]"',1);
insert into macrodetail values ('PING',7,38,'',0,'ph_deletefile ( "c:\ping.txt" )',0);

Called as shown previously, it should return "Online" or "Offline".

PS: You made it easy to post +'s!
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: May 24 2005 at 09:17 | IP Logged Quote dhoward

Tony,

Found the problem...but no real good way to fix .

The trouble is the "Wait" command. As soon as a macro waits, it stops executing and control is returned back to whatever called the macro. So it's returning the "[LOCAL1]" value properly, it just hasn't been changed yet. The only way to fix this would be to change the "Wait" command to a "Delay" command.

You may be to come up with some different coding...where the first part of what you're doing calls the "PING" macro and when the "Wait" is complete, the "PING" macro calls another macro to complete your processing (perhaps passed in the "[LOCAL5]" var)

HTH,

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: May 24 2005 at 14:09 | IP Logged Quote TonyNo

Thanks, DTG. I knew it was something strange.

I'll work up a solution tonight and post it up.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 

Page of 2 Next >>
  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