cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
nathan-clark
Level VI

Gracefully terminate Run Program()

I am in a situation where I use Run Program() to send files to an FTP/MTP site. By and large everything works great, but sometimes there's a kink in the connection and the program lags indefinitely. I have recreated this problem from the command line and it's basically a lost connection type event. But I need to Ctrl-break out of CMD to stop it.

 

In JMP I want to put in a timeout to reduce the risks, however I haven't been able to get one to work well. Currently I build the timeout into the While(!(x << isReadEof), Wait(0.1)) command such that x is set to 0, breaking the Run Program. But when I do this JMP will often freeze for a short or longer time to fix (or while something else is fixed) background stuff that had been going on.

 

Is there a way to force close Run Program() as well as the process it invoked w/o risk to freezing JMP?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
nathan-clark
Level VI

Re: Gracefully terminate Run Program()

Thanks for the idea @Craige_Hales! I had tried the <<write "bye" before, but without the <<writeEoF ... so perhaps that would make a difference. I had thought of other FTP clients, but this script would be used across a larger user base on which I can't control the FTP client piece.

 

If I find a solid thing that works, I'll post it here, but I'll def try some of your ideas!

View solution in original post

2 REPLIES 2
Craige_Hales
Super User

Re: Gracefully terminate Run Program()

Try rp<<write the appropriate quit or exit commands to the FTP program, followed by rp<<writeEOF. (Although, as you say, the FTP program appears to ignore everything while the connection lost is hanging.)

 

When the JMP variable holding the RunProgram object (rp in my examples) is overwritten or destroyed by JMP ending, it will wait for the ftp program to finish. I don't think there is a way to send the ctrl-break through the FTP stdin.

 

I think the lost connection hang may last as long as 10 minutes by default and may be configurable; I'm not sure whether that would be in the FTP program or in a windows registry setting. For my test it seemed to hang about 1 minute.

 

All my experiments were done with the builtin windows FTP client. There are probably other clients that might have different features.

Craige
nathan-clark
Level VI

Re: Gracefully terminate Run Program()

Thanks for the idea @Craige_Hales! I had tried the <<write "bye" before, but without the <<writeEoF ... so perhaps that would make a difference. I had thought of other FTP clients, but this script would be used across a larger user base on which I can't control the FTP client piece.

 

If I find a solid thing that works, I'll post it here, but I'll def try some of your ideas!