Open a command line from a program in windows/osx

60 views
Skip to first unread message

Bobby

unread,
Dec 4, 2015, 6:35:29 PM12/4/15
to Haxe
I have a program that will run a simple psychology experiment in windows/osx. The data are saved in .txt files. I'd like to have these files automatically upload to a server via FTP.  

Previous posts suggest it is easiest to do such FTP transfers via the command line, but I can't see an obvious way to open a new command line from my windows/OSX program and write to it. 

Could anybody give me an example of how to do this? In case it is relevant, my program is built as an OpenFL project.

Ashiq A.

unread,
Dec 4, 2015, 6:47:48 PM12/4/15
to haxe...@googlegroups.com
http://api.haxe.org/sys/io/Process.html if you need to capture output

Otherwise, you can try http://api.haxe.org/Sys.html#command

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Bobby

unread,
Dec 4, 2015, 7:09:47 PM12/4/15
to Haxe
Thanks, but that doesn't seem to work as I'd hoped. Command is printed to the same output as the current process. What I need is a way to open up a separate command line prompt and write commands to it.

Ashiq A.

unread,
Dec 4, 2015, 9:21:59 PM12/4/15
to haxe...@googlegroups.com
Did you try Sys.io.process?

Bobby

unread,
Dec 4, 2015, 10:14:50 PM12/4/15
to Haxe
Yes - apparently it can't be called (i.e. I don't understand how to use it to open the command line, or any other program).

Could you give a specific example of how you would implement this? The documentation isn't very thorough so I don't see how it would be implemented.

Also, thank you so much for your responses! It looks like the capability is there, it's just a case of getting an example and adapting it to my needs.

Ashiq A.

unread,
Dec 4, 2015, 10:23:06 PM12/4/15
to haxe...@googlegroups.com
I don't have much experience with Haxe, sorry. I don't have a working example I can show you.

Documentation is generally scarce. You can experiment and see how it works.

Bobby

unread,
Dec 5, 2015, 12:10:01 AM12/5/15
to Haxe
No worries - talking to you is helping me work through the possibilities, so thanks!

Bobby

unread,
Dec 5, 2015, 12:41:24 AM12/5/15
to Haxe
And thanks to your suggestions I've managed to get this working - thanks so much!

for future reference: var p = new Process("calc", []);

Cristian Baluta

unread,
Dec 5, 2015, 3:09:31 AM12/5/15
to haxe...@googlegroups.com
On osx you can use applescript to do stuffs. Apparently this opens a new window
osascript -e "tell application \"Terminal\" to do script \"cd $pwd; clear\"" > /dev/null

Justin L Mills

unread,
Dec 5, 2015, 1:35:21 PM12/5/15
to haxe...@googlegroups.com
I believe you can use the enhanced std library found here without direct
use of terminal.
https://github.com/MarcWeber/haxe-std/blob/master/std/mtwin/net/Ftp.hx

An old example can be found here:
http://old.haxe.org/com/libs/mtwin/net/ftp

For general file reading and writting maybe my search and replace
experiment helps, if you have not already worked that bit out.
https://github.com/Justinfront/SearchReplaceText

Best

Justin
Reply all
Reply to author
Forward
0 new messages