#Pass stdin to OS.execute() call?

1 messages · Page 1 of 1 (latest)

ivory jasper
#

I have a program I want to call with OS.execute, but I must pass a string to it. In powershell, I would type echo "the string" | ./program.exe args but how do I do that from Godot?

winter trellis
ivory jasper
#

Aren't those the args for the program rather than the stdin for it?

#

Ah. It is slowly dawning on me now ... follow up question, then; how do I safely navigate to user://?

dusty token
#

I was just about to answer how to send an stdin input to the program. I'm guessing you have that side figured out then?

ivory jasper
#

I think so. I run "CMD.exe", and then my args concern what CMD is to do ... so when I get to where the program is supposed to be, I write the arguments out.

#

I had originally the path set to "user://program_folder/program.exe", but that was obviously wrong.

dusty token
#

For your other question, there is a function in OS for getting the user:// called get_user_data_dir()

ivory jasper
#

ah, so I can use that to generate the cd call in the array 🙂

dusty token
#

Exactly, yeah.

ivory jasper
#

Thanks a bunch. Will try it out now 🙂

#

What is the "C/" for at the beginning of args?

dusty token
#

It's a command that tells command prompt "Run whatever comes after this, and then close." It's how you tell it to do something, rather than just opening and waiting for input from the user.

ivory jasper
#

Thanks again for this! Excellent help 🙂 OS.execute now returns 1, so it seems to work - the text-to-speech program on the other end, however, does not produce the file it would normally. Another puzzle 🙂