runprogram() question

Just starting out? Need help? Post your questions and find answers here.
dmontaine
User
User
Posts: 50
Joined: Tue Jun 04, 2019 1:03 pm

runprogram() question

Post by dmontaine »

Why does this program not work in Linux?

Result = RunProgram("/usr/bin/xterm","-help","~")
Debug(Result)

Result shows 1 however terminal window does not appear

However, this program without parameters does work.

Result = RunProgram("/usr/bin/xterm")
Debug(Result)

Testing with Linux Mint LMDE 6
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: runprogram() question

Post by jassing »

dmontaine wrote: Sat Sep 30, 2023 6:19 pm Why does this program not work in Linux?

Result = RunProgram("/usr/bin/xterm","-help","~")
Debug(Result)

Result shows 1 however terminal window does not appear

However, this program without parameters does work.

Result = RunProgram("/usr/bin/xterm")
Debug(Result)

Testing with Linux Mint LMDE 6
I'm not a linux user... so this is just a guess.

for the "-help" version, xterm runs and exits. so the program has run and exited.
You need to use the constants for reading stdout.

For the "xterm" only (no -help) it launches the program and waits for it to finish.
infratec
Always Here
Always Here
Posts: 7577
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: runprogram() question

Post by infratec »

Yes,

if you want to capture text output you need the additional Flags for RunProgram() and read the values.
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: runprogram() question

Post by Marc56us »

dmontaine wrote: Sat Sep 30, 2023 6:19 pm Why does this program not work in Linux?

Result = RunProgram("/usr/bin/xterm","-help","~")
Debug(Result)

Result shows 1 however terminal window does not appear

However, this program without parameters does work.

Result = RunProgram("/usr/bin/xterm")
Debug(Result)

Testing with Linux Mint LMDE 6
It probably appears but closes so quickly that you don't have time to see it.
If the help displayed is less than one screen page long, then the default pager ("more" or "less") (if set) is not called and the program is terminated, so the shell window (xterm) closes.
Try use #PB_Program_Wait : Wait until the launched program quits
juergenkulow
Enthusiast
Enthusiast
Posts: 581
Joined: Wed Sep 25, 2019 10:18 am

Re: runprogram() question

Post by juergenkulow »

Compiler Executable

Code: Select all

RunProgram("/usr/bin/xterm","-help","~")
Terminal or xterm:

Code: Select all

kulow@kulow-G73Jw:/tmp$ ./xhelp.out
kulow@kulow-G73Jw:/tmp$ XTerm(372) usage:
    xterm [-options ...] [-e command args]

where options include:
    -/+132                       turn on/off 80/132 column switching
    -C                           intercept console messages
    -Sccn                        slave mode on "ttycc", file descriptor "n"
    -T string                    title name for window
...    
Post Reply