Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: ph_run Doesn’t Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 942
Posted: January 21 2009 at 09:49 | IP Logged Quote GadgetGuy

I have several compiled VB snippets that manage image files for me to create a rolling FIFO collection of images for web viewing. The manipulated files reside in the same folder as the executable, with the exception that several images are up one level in the PH web folder.

While both programs function fine by themselves, neither works when called from PH.

For simplicity, I will just discuss one here, as if that can be made to work, the other will follow.

A VB executable called "MovImgs.exe" is located in "CamImgs", a subfolder of the PH Web folder, and when "MovImgs.exe" therein is double-clicked it performs exactly as it should. It pops up the Command Shell window, manipulates the files and closes the window all within seconds.

When I try to run the same executable from within PH, however
Code:
ph_run("C:\Program Files\powerhome\web\CamImgs\MovImgs.exe")
all that happens is that the Command Shell Windows opens then closes within a fraction of a second, and no file manipulations occur.

This appears to be another one of those maddening situations where all seems exactly right, but clearly something is wrong in what I'm doing or I have discovered another bug.

Any ideas?

__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 942
Posted: January 21 2009 at 11:42 | IP Logged Quote GadgetGuy

I think I have discovered a bug. When I put my executable in the "web" folder of PH then the ph_run() function works, but if the executable is one layer deeper within a folder in the web folder then it either crashes PH or the executable doesn't run even thought PH gives me a "successful" return code from the ph_run() operation.



Specificallly if the executable is located in CamImgs or WthrImages then the ph_run() effort fails, but if I move the exe to the 'web' folder itself, then things run and do not crash PH in the one case.

It appears that the ph_run() command cannot parse the extra folder depth in the path name. Thus:
ph_run("C:\Program Files\powerhome\web\MovImgs.exe") works,
but
ph_run("C:\Program Files\powerhome\web\CamImgs\MovImgs.exe") does not.

Dave?

Edited by GadgetGuy - January 21 2009 at 11:43


__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: January 21 2009 at 12:07 | IP Logged Quote grif091

What are you doing in the VB program to access a subfolder above the folder containing the executable. Rather than moving the executable up to the folder containing the files, have you tried moving the files down to the executable folder (just for a test).

__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 942
Posted: January 21 2009 at 15:06 | IP Logged Quote GadgetGuy

Lee - thanks for your suggestion. I have tried that before without success. Been fighting this for over a day.

Then just a short while ago when playing around I discovered that if I moved the exe into the PH web folder things ran. Subsequently in running futher experiments I put it back in the sub-folder and damn if it didn't run without crashing PH. Not only that but it ran and produced the correct results! Still can't figure out what or why in all that. I changed nothing but moving the exe out of and back into its original folder.

That left the second exe to get running (the animated weather map maker). It never crashed PH but I never could seem to get results. In experimenting more, I discovered a few minutes ago that this animated GIF maker, which runs from the Shell Command Line is confused by PH.

Normally this GIF Maker gets and puts its file from within the folder it is running in. But since it was kicked off by a ph_run() command from PH, the App seemed to think it should be doing things in the PH root folder instead of it's own. It was finding none of my files there but valiantly tried to make a GIF which was empty and put it in "C:\Program Files\powerhome" instead of where I expected it. By accident I saw the GIF in the PH root folder when looking for something else.

So, long story short. Two different problems with two different solutions, but I'm a happy camper again.

EXCEPT after all this work my %$#@!^!! iPhone does not seem to display animated GIFs if they are bigger than a thumbnail, so now I need to find out why and fix that!

Oh well, more entertainment for a snowy day.

__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: January 21 2009 at 16:43 | IP Logged Quote dhoward

I cant say for sure, but most likely both problems are caused by the current directory. The ph_run command launches an executable but is at the mercy of whatever the current directory is. Most of the time, the current directory from within PowerHome will be the default c:\program files\powerhome directory but this can be changed by various file open dialogs so you never know for sure. Even though you explicitly specify the full path and executable within the ph_run command, the current directory is something else entirely. This is similar to if you opened a cmd.exe window, set the current directory to some random location and then typed the full path and exe to your program. The program will run, but may not produce the desired results if it was expecting to be executed from the same directory that the program resides in.

A couple of ways to work around programs that must be executed from within a particular directory. You can create a .bat file that changes the current directory and then launches the executable. You can then use ph_run to call the .bat file. The more "Windows" way to accomplish this is to create a shortcut file that launches the executable and declares "Start In" directory to be the location of the executable.

The only trick here is how do you get the ph_run command to launch a shortcut? Below is an example of how to do it:

ph_run('cmd /c "C:\Documents and Settings\All Users\Desktop\YOURSHORTCUT.lnk"')

This will launch a shortcut located on the desktop. You can adjust the path as desired for shortcuts located elsewhere. The only problem with this approach is that you'll see a quick flash of the CMD window open and then close. However, this is the ONLY way Ive found to be able to launch a shortcut from the ph_run command.

Hope this helps,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 942
Posted: January 21 2009 at 22:24 | IP Logged Quote GadgetGuy

Dave - As always a perfectly awesome job of replying! I can't help but say that you are rather incredible, and much appreciated!

I've solved the Directory problems but it required me to build quite a full path string that was quite complex.

It takes up three lines in my VB code window.

But I now have a nice animated US Surface map that no source I could find seems to provide. The static map lives at:

   http://image.weather.com/images/maps/curre nt/curwx_600x405.jpg

but it is not animated. I find it very useful to see the integrated radar, isobars, and pressure zones all on one map, but it really becomes usefull when you can see it animated over 4 hours, or so.

Using PH's saveitcurl function I was able to grab a map every 45 minutes and then make a FIFO list to feed to a neat command line GIF maker I found (www.neomesh.com/content/view/10/33/) that takes separate images and makes them into an animated GIF.

The result is exactly what I wanted. Thanks ever so much for making it all possible. I now have an extremely usefull and handy personal web page with weather, security camera images and lighting control all due to the wonders of PH.

Now if I can just get the iPhone browser to refresh when I tap a lighting button in the CC and show its changed state, I will be the ultimate happy camper!

__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 

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