I'm trying to create a button that runs one command and when then command has finished runs a second command.
The function of the button is to create a ssh connection to a server using putty.exe and then initiate a vnc connection to the server via ssh using vncviewer.exe.
The problem I have is that if I use the @sync command it runs the first the first command but then just sits there until I close the dos window, which closes the ssh connection and causes the vnc connection to fail . If I change the command to @async then the second part runs before the first part has finished so I get an error.
Is there a way round this so that the vncviewer function runs after the putty has establishes a connection? If there's no way to get vncviewer to wait until putty has made a connection then a wait command should do the job but I didn't see such a command when running through the docs.
No you're not. You need the first command (PuTTY) to continue running else the second command won't work, as you said.
In general, there is no way for Opus (or any other program) to know when another program is "ready". Opus can run a program and can then tell when (if) it exits completely, and optionally wait for it to exit, but there's no way for Opus to know that PuTTY has established a network connection and is now waiting to for network data.
(There is thing in Windows that lets a one program launch another and then wait until the child program is "idle" but what "idle" means is very fuzzy and I doubt will apply in PuTTY's case.)
If PuTTY had some kind of option to run a command once a connection was established then that would be the thing to use. I'm not sure whether or not it has such an option, though.
Yes your right of course, should have wrritten that better. The Putty window has to stay open otherwise the connection drops and the vnc software won't work.
Is there a wait command I can use? I could then run the putty command, wait 3 seconds and then run the vnc command.
I couldn't find an opus wait/sleep command so i've had to use the ping command to get this to work.
Now that i've got it to wait i've got another question. I want a popup to open asking me for a password which will be passed to both commands (putty and vncviewer). So far i've got the code below which opens a password dialogue and passes the password to the putty command but how do I pass the same password to the vncviewer command as well without having to ask and type it in again? I need the password to go where it says PASSWORDHERE.
The good old ping hack. There are some more explicit "wait 5 seconds" commands but none I know of that are built into Windows so I guess using ping has a certain appeal.
Anyway, on to your question, that's easy to do. The manual's Command Control Codes section near the back has an example to do with creating a directory but it should be easy to adapt for your command:
@set dir = {dlgstring|Enter new folder name to copy files to}
createfolder ".\{$dir}"
copy to".\{$dir}"
The @set command sorted out the password problem, the button now works fine. The ping trick is messy and I don't like it but it works so that's the main thing. Cheers Nudel.