0

I have a .sh script Call mainSc.sh which look like this :

#!/bin/bash
{
cd /home/myrepository
export LD_LIBRARY_PATH=/home/myrepository/build/src/
./myscript.sh | python mypythonscript.py
} || {
notify-send "it didn't work..."
}

And my problem is when I launch it from terminal (./mainSc.sh ) it work fine and when I try to launch it from the .desktop I created, it launch and work until ./myscript.sh and my python script does not work... I really don't understand why....

thanks a lot !

2 Answers 2

1

This behavior can be explaned easily if you are dealing with the standard input in myscript.sh (waiting for user input, for example). As no terminal is attached, your script terminates, just like cat would do, for instance.

5
  • Thanks for your answer. Can I open and attached a terminal to this process to resolved that ? if yes, how ?
    – Dadep
    Jul 29, 2016 at 19:01
  • The best way to do it would be to change the script myscript.sh itself. There is really no point in running a command line program within a graphical environment if it requires some textual interactions. Depending on what myscript does, however, you could use a GUI to communicate with it, send it a default command when launching the script, or, more complex, feed it an open named pipe that you close afterwards. But really, modifying myscript.sh is the best solution here, if you can afford it.
    – MayeulC
    Jul 29, 2016 at 19:14
  • myscript.sh launch a code (in c++) which just make online video analysis (detect event), as far I know there is no input, only output. this output I want to send it to the python script I did. Which get the "online" information from the first code and count the number of event and then write on serial port. ...
    – Dadep
    Jul 29, 2016 at 19:22
  • You could probably try to use screen if that's an option for you: screen -t "mainSc" 2 bash -c '/my/script.sh' (or just write your entire script between those quotes). I am not sure if bash -c is necessary here.
    – MayeulC
    Aug 1, 2016 at 6:09
  • I did know screen, I will have a look it could be a solution. I've found that I had some problem with python execution.
    – Dadep
    Aug 1, 2016 at 13:05
0

Thanks to MayeulC I found an alternative :

launching in a terminal, my command in my .desktop is now :

gnome-terminal -e /home/myrepository/myscript.sh

in this way I can monitor the execution of all codes and solve problem in an easier way !

I discovered that my python script was not execute by the same version of python when I was launching it by the .desktop or from terminal (but I don't know why yet).

I'll work on it ! Thanks

Dd

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .