One app depends on terminal to work

Post

Posted
Rating:
#1 (In Topic #1454)
Regular
sergioabreu is in the usergroup ‘Regular’
 Hi everyone

I have made an app that uses Shell to run scripts and return values. The launcher on DESKTOP only works if I mark "Run in terminal"
It seems it is depending on a terminal attached to work.
If I mark Run on terminal or open it from a terminal, it works correctly.
The Desktop laucher without "Run in terminal" does not work totally and I confirmed it is related with Shell commands in my code that returns empty in this situation

Some clues to solve it ?

Regards
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
sergioabreu is in the usergroup ‘Regular’

Problem SOLVED !

I discover the problem was related with the command itself that was run on Shells

Basically one script could receive the "param" from command line OR from pipe (accepts both)

In terminal both work:
$ oneapp arg1
$ echo arg1 | oneapp

But in gambas I will have to use only PIPE to work always.

Code

   Shell "echo " & myvar & " | oneapp " to avar   'Works, avar gets it
   
   Shell "oneapp " & myvar to avar ' Fails without one terminal attached. avar gets empty
   

But via PIPE works always.

Regards,

Sergio
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’
some commands can return the text to stderr not stdout.

you can simply re-direct stderr to stdout using 2>&1

like this…

Code (gambas)

  1.  
  2.   Shell "oneapp " & myvar & " 2>&1" Wait To avar
  3.  
  4.  


Some programs (like ffmpeg) need a terminal and require a proper input/output handler.

that can be handled like this..

Code (gambas)

  1.  
  2. Public Sub Form_Open()
  3.  
  4.   Shell "oneapp " & myvar For Input Output As "PROC"
  5.  
  6.  
  7. Public Sub PROC_Read()
  8.  
  9.   Dim sReturn As String
  10.   sReturn = Read #Last, -256
  11.   Debug sReturn
  12.  
  13.  
  14.  
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
sergioabreu is in the usergroup ‘Regular’
 Thank you man
Nice
Online now: No Back to the top

Post

Posted
Rating:
#5
Regular
sergioabreu is in the usergroup ‘Regular’
 I didn't know this Wait, seems important
Online now: No Back to the top

Post

Posted
Rating:
#6
Regular
sergioabreu is in the usergroup ‘Regular’
 I tested your first suggestion and didn't work.
The funny is that on the IDE it runs, as my original code too.

Pipe someways save from problems.

Hope this help others. Use pipe if possible
Online now: No Back to the top

Post

Posted
Rating:
#7
Regular
sergioabreu is in the usergroup ‘Regular’

Mistery off

I finally found the problem.

If you use ARGV to pass to python and this python program also checks STDIN (pipe), it generates the conflict with gambas.

If a python script checks the state of pipe (stdin) I can not pass values only via command line in gambas, because when python checks stdin the conflict occurs. The terminal solves the "STDIN hunger" of python allowing the ARGV free to work with gambas.

To use only command line args I would have to stop this PIPE checking in python. So I decided to send always with pipe allowing the python have both ways.

In other words:
If a program has PIPE support (stdin), you have to use this method when passing values from gambas, or it wil "ask for a terminal".

Now the desktop launcher works too, even without terminal.
Online now: No Back to the top

Post

Posted
Rating:
#8
Guru
BruceSteers is in the usergroup ‘Guru’
cool
Online now: No Back to the top
1 guest and 0 members have just viewed this.