Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 9:20 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Communicate with CMD...
PostPosted: August 10th, 2011, 10:47 am 
Offline
User avatar

Joined: October 31st, 2010, 9:53 pm
Posts: 10
Location: PARIS FRANCE !
Opus: Pro 6.4
OS: WinXP, Win7, Mint
System: too long to tell...
Hi all !

I have a problem, I made a little pub to ask for a folder and copy files in it via CMD.

:arrow: my pub ask for a folder, its path is saved in a variable,
:arrow: the pub wrote this variable in a .BAT,
:arrow: launch the .BAT...
...but I would like something to happen when the .BAT finish its work (copies).
:idea: I thought that my pub would do some kind of a loop-search for a file (that the .BAT delete at the end of the process), and when the file will be deleted, the pub reacts...
(it can be the same with writing something in the registry) but I don't know how to check the file/registry 'til it happends...
It's maybe not the easiest way to do this, but I didn't find anything else so...

If you have ideas about "communicate" with a CMD in this way...or another...I'll take it !

(Sorry for my poor English, I'm French ! :mrgreen: )

Riki.


For this message RikimaruHazuma has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Communicate with CMD...
PostPosted: August 11th, 2011, 5:27 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Probably many ways to achieve, depending on what you intend and what level of tech skill.

One possibility:
Create a simple .txt file, for example: marker.txt
When the .bat has finished its task, have the .bat copy marker.txt to a Folder related to your Opus Pub (so that Opus can later delete that copied file).
When you start the .bat running, set some status variable to 'started' and have Opus check FileExists() in that Folder. You said loop... so yes do that and simply put a wait(0.2) or some other delay interval. Once you detect that the market.txt files exists in the particular Folder, change your status variable (e.g., 'done') and ALSO have Opus delete marker.txt from that folder. Exit the loop (your IF condition can be a test on your status variable).

FYI, Opus has a Standard Trigger called: variable changed or something similar.
That might come in handy somewhere.

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Communicate with CMD...
PostPosted: August 12th, 2011, 10:39 am 
Offline
User avatar

Joined: October 31st, 2010, 9:53 pm
Posts: 10
Location: PARIS FRANCE !
Opus: Pro 6.4
OS: WinXP, Win7, Mint
System: too long to tell...
Hi, and thanx for replying but when you wrote "...and have Opus check FileExists() in that Folder", It's exactly what I want to do but I don't know how to do that :( I only use buttons and actions defined, I never used programmation if it's what you're talking about...
And I think that I'm going to copy the "marker" at the begining of the BAT process and make Opus check and reacts when the "marker" will be deleted at the end (to avoid another extra action at the end...).
So if you have seconds for me and can explain clearlier or put down a bit of code...It'll be awesome.
Anyway, thanx for takin' time for me. :D


For this message RikimaruHazuma has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Communicate with CMD...
PostPosted: August 13th, 2011, 9:55 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Quote:
I don't know how to do that :( I only use buttons and actions defined, I never used programmation if it's what you're talking about...
Yes. That is what I am suggesting... OpusScript. I see that Opus Standard Actions does not give you that command as a preset Action. It would not take much time ( a very few small minutes ) to add three or four lines of opusscript code to a Standard Action.

However, it is the weekend and I do not have my brain tuned to this right now.

I wonder if a simpler approach might work. ???
Do you think you can get your .BAT file to write a string to the Windows Clipboard?
Then you could use Opus Standard Actions to retrieve Clipboard contents and place it in a variable. Then test for that variable to be a certain string value. (One problem with this approach is if the User is going to be doing something else and also using the Clipboard.)

I did a quick search and found this page that might help you.
http://superuser.com/questions/231023/w ... -clipboard

If you cannot get that to work, or you want to stay with the test of File EXISTS, post back and somehow we'll try to get that working.

[EDIT lar]Okay, I took a little bit of time to check this out. It seems that using the one line of code from the 'superuser' link... does not work for me on Vista. Could be UAC or any number of other things.
I leave it to you to Search/Google further on this, if you believe it holds promise.

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Communicate with CMD...
PostPosted: August 14th, 2011, 9:10 am 
Offline
User avatar

Joined: October 31st, 2010, 9:53 pm
Posts: 10
Location: PARIS FRANCE !
Opus: Pro 6.4
OS: WinXP, Win7, Mint
System: too long to tell...
Hi, I'm gonna test that right now, and tell you, I found some others things to test too, I'll keep you in touch, thanx Dude ! :D

Edit : well, an hour after...still doesn't work. :|
This what i did and test :
:arrow: With the registry, add a .reg at the end of my BAT which wrote "DONE" in the registry, and make Opus check 'til it find...
:arrow: With copying a DONE.TXT at the end of my BAT, and make Opus check 'til it find it...

In both case, it doesn't work, but I'm not sure about my "Loop" function...It might work but not with what I "only" know...

Some pix of what I did :

Image
Image
Image
Image

Maybe my steps are wrong, but with pix you'll see brighter :wink:
The "clipboard" way can't be the way, because, as you said "(...)User is going to be doing something else and also using the Clipboard.", and as the job ask for some mins...user will continue using his computer...


For this message RikimaruHazuma has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Communicate with CMD...
PostPosted: August 14th, 2011, 5:32 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Take a look at your step: Loop while if fileexists...

1) Change the expression under test to simply: reg
...so it will be: Loop while reg

2) take the IF Statement you previously wrote, and put it in a Script action.
So... BEFORE the Loop, insert another Action. Look under the 'Programming' Tab and find the Script action. Simply put your if statement there, so that it sets your variable, reg to TRUE (reg = TRUE).
NOTE: you need Curly Brackets in your IF Statement

Code:
if (test_condition)
{
do something
}  //end if here

- - - - - - - - - - -
OpusScript is picky about how a file Path is written. You seem to have it correctly with the double back-slash -- and that would be true if you were writing the string to represent the path. However here, Opus is highlighting a possible syntax error in 'red' \\.
However, check Duncan Lilly's post here:
viewtopic.php?f=6&t=2026&hilit=path
- - - - - - - - - - -

cheers,
Larry

BTW, be careful about using such simple Object names and maybe variable names, e.g. OUI and reg. They may be easy to duplicate (use twice), or they may conflict with reserved keywords. So my caution here is a general one: Do not use the same name for an Object and a variable. Opus Page will either throw an error, or simply not run correctly. And the same thing applies if you forget to use unique object names within a Page (names can be used again if they are in a separate hierarchy... e.g., in a different Frame -- Frame01 and Frame02 can each have an object named Square_1.)

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Communicate with CMD...
PostPosted: August 14th, 2011, 7:44 pm 
Offline
User avatar

Joined: October 31st, 2010, 9:53 pm
Posts: 10
Location: PARIS FRANCE !
Opus: Pro 6.4
OS: WinXP, Win7, Mint
System: too long to tell...
...I'm lost... :(
Maybe it'll be obvious in French but in English...it's like another dimension... :shock:
Just to a have a chance to make all of that even more clear...my project was made to backup 2 folders from user's computer.
The project ask for the destination's folder and copy these 2 folders in it.
Until there, all works fine as I expect...BUT the..."come back" is so...tricky.
I really do my best to hold out but... :(


For this message RikimaruHazuma has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Communicate with CMD...
PostPosted: August 14th, 2011, 10:22 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Quote:
.it's like another dimension... :shock:
Apologies. Even without the language, the 'solution' I outlined may be difficult for others to follow. It is not a correct solution. I was focused on cleaning up the syntax, and I did not examine your logic flow closely. So I overlooked several other problems in the actions (your screen capture pics).

So let me start over. [Edit lar:] To help further, I decided after writing this post to provide a sample Pub. It has actions that should work for you, but pub page will not run since it is incomplete -- but you can Open the .imp in Opus and Copy & Paste the already constructed Triggers and Actions from the sample Pub to your own Pub. You just have to make sure your Object names and variable names match the ones I used.

1) in the Standard Actions, after you Launch the .bat --- replace the Loop action you constructed with the following Loop action.
This loop runs on the condition that variable reg1 is false. [ !reg1 means 'not reg1' ]
Click pic 1 to see larger.
Attachment:
for Opus_std actions_1.jpg

2) add a Script Action as shown (pic 2). Enter the opuscript code as shown.
Code:
if (FileExists( SYSTEM_TEMP_DIR + "DONE.txt" ))
{
reg1 = true ;
}
This will test ONE TIME whether file DONE.txt exists in that directory. The Loop will of course run the script action several times. I would put a Delay action as shown -- so that the loop paces itself.
Attachment:
for Opus_std actions_2.jpg


3) Next, you use an Action for an IF Statement... or as I am showing, use by using SELECT & CASE Actions to achieve the same thing. (see pic 3).
Attachment:
for Opus_std actions_3.jpg

Initially the var reg1 should be false. In the SELECT & CASE structure for true/false, that branch runs as the default. ( and I show an Animation Action 'Fade' (it is actually a pulsing of the text). You could choose to do nothing -- no anim. )
(see pic 4 in the next post)

But when CASE true (reg1 is true), the Actions under that branch... run animation to indicate to the User that the operation was completed.
(see pic 5 in next post.)

4) Let's assume that the .BAT completes successfully. The Script Action created earlier will find that the File Exists, and it will set reg1 to true. After the animation sequence, the Loop will loop-back again but this time encouter reg1 is true ( !reg1 is false ), and the Loop will exit.

I did not take time to test this, but I am hopeful it is right and workable. If not, post back what you observe.


You do not have the required permissions to view the files attached to this post.

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Last edited by Lar_123 on August 15th, 2011, 12:33 am, edited 6 times in total.

Top
 Profile  
 
 Post subject: Re: Communicate with CMD...
PostPosted: August 14th, 2011, 10:24 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Here are pic 4 and pic 5 as mentioned above.
Cheers, lar

Attachment:
for Opus_std actions_4.jpg


Attachment:
for Opus_std actions_5.jpg


You do not have the required permissions to view the files attached to this post.

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Communicate with CMD...
PostPosted: August 14th, 2011, 10:48 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
A Sample Opus Pub is attached.

Note: it has Actions that will not run -- not all of the set-up is complete. (I am just providing to you can Copy the 'Oui' Button to a Page in your own Pub. When Pasted, that Button will have the Triggers & Actions as well. See the comments note on the page). Good luck.

ps. Opus allows you to Copy and Paste individual Actions, or individual Triggers with their action tree included. Saves time and work.


You do not have the required permissions to view the files attached to this post.

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Communicate with CMD...
PostPosted: August 15th, 2011, 10:31 am 
Offline
User avatar

Joined: October 31st, 2010, 9:53 pm
Posts: 10
Location: PARIS FRANCE !
Opus: Pro 6.4
OS: WinXP, Win7, Mint
System: too long to tell...
Thanx to put yourself on a lower (human) level :D "Godlike" often forget us, poor little ants ! :D

So I tried to do all written but I'm blocked on the branch just under the SELECT action, I'm unable to set this action to "true" like on your sreenshot :
Image

Edit (few mins later) : OK ! I made another CASE, select the radio Value and wrote "true", and keep the another for the "untrue"... I'll go further to see if it works...

And Thanx for the pub but...after asking me to open it anyway (because it has been made with a newer version of Opus) :
Image

It's so frustrating to know that you're so close to make it work...and it doesn't ! :x

PS : I'm on Skype if you wanna try something in real time :wink:
Be sure that if we'll do something via Skype to make it successful, I'll be back here to explain the solution for...some other ants ! :D


For this message RikimaruHazuma has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Communicate with CMD...
PostPosted: August 15th, 2011, 10:53 am 
Offline
User avatar

Joined: October 31st, 2010, 9:53 pm
Posts: 10
Location: PARIS FRANCE !
Opus: Pro 6.4
OS: WinXP, Win7, Mint
System: too long to tell...
So it seems to work but (once again), I changed the code in my BAT to make it faster, but in fact when I make it slower, the pub seems to go to "the end" directly. It might be because, as the DONE.txt wasn't deleted each time I launch it, it's like it's already OK as it's already present...I have to make the pub delete this file if it exist at the beginning...I put that :

Image

I hope that it won't gonna display an error message if it doesn't find the TXT... :? :arrow: Edit : It doesn't and do its job perfectly

we leave the Alpha versions to reach the RC ones ! :D

:arrow: Edit : Not yet...when I launch the pub, all the beginning works fine, but when the BAT is closed, nothing more happen...the pub stand still on the "copy in progress..." screen...


Another "little" thing...why can't I insert a variable in a text object ? version detected via reading registry and display it on the main page of the pub...
Image


:arrow: Edit : It seems to work ! I replaced the !reg by "just" reg on your pic1 :!:
Two little problems remains :
1 - When I click on the "OUI" button to let the user choose his destination folder, a window opens to make this choice, but if I click Cancel (Annuler in fact :wink: ) the script continues (without copying but continues as well...)
2 - My "variable in a text object" thing...


RE-EDIT : I think that my Opus is haunted ! :(
In testing purpose I replaced my XCOPY command by a PING one, and all work fine, but when I write back my XCOPY command in my BAT, it doesn't work anymore...the copy works fine, but it stay on the "copy in progress..." screen...
1 step forward...2 backwards... :(


For this message RikimaruHazuma has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Communicate with CMD...
PostPosted: August 15th, 2011, 6:03 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Do not have skype.

Quote:
:arrow: Edit : It seems to work ! I replaced the !reg by "just" reg on your pic1 :!:

:arrow: Edit : Not yet...when I launch the pub, all the beginning works fine, but when the BAT is closed, nothing more happen...the pub stand still on the "copy in progress..." screen...
Three things about that. If you are using reg as your variable, then you must review all the Actions I sent (for correct and consistent naming), including the small Script Action as reg is set there. 2) Then, reg or !reg -- you can use either way, but you just need to KNOW what you are testing for... e.g., I tested for !reg EQ true. You could test for reg EQ false. You need to have the correct actions under each CASE -- check your logic.

Maybe you could go back and use IF Statement, if that is simpler for you.

3) Somewhere you must set reg to false. I did not do that part because I thought you may already have it somewhere. Think about it this way: at times, reg should be false... and when file exists, it is true. But as you know, DONE.txt needs to exist when BAT is complete, and needs to be deleted before BAT runs.

Suggestion: to debug, you will have to display values of variables at certain steps to see what is going on. You can also track which branch of logic is taken -- by putting in some temporary animation. ( within any scripting, you can use the Debug.trace( some_expression ) to see data realtime ). You may want to create extra delays to slow down sequences while testing.

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Last edited by Lar_123 on August 15th, 2011, 6:12 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Communicate with CMD...
PostPosted: August 15th, 2011, 6:08 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Quote:
my XCOPY command in my BAT, it doesn't work anymore
Do some google research on that AND vista / win7

e.g., http://social.technet.microsoft.com/For ... e0d0eb7a5/


Quote:
why can't I insert a variable in a text object ?
You have it working now, but in general -- Make sure you have Clicked on the Text Object so that you are in Edit mode and have cursor positioned where you want. Should work.

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 28 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group