Tuesday, May 7, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 10587  / 3 Years ago, thu, august 12, 2021, 7:32:40

I am using Ubuntu since the version 10.04 and found it more friendly as compared to Windows. Right now I am using ' Precise 12.04`. I have created many custom launchers for bash scripts, and never had any problem until yesterday.



I have installed a software suite which has multiple executables. The main executable abaqus is located in optsoftwaresname and is a symbolic link to the executable abq610i in /opt/softwaresname/executables/.



The main exe abaqus requires some command-line arguments. I use the argument cae, (i.e. abaqus cae) but with another command to render the graphics in a better mode, hence the final call is:
XLIB_SKIP_ARGB_VISUALS=1 abaqus cae



I made an alias for this long command in .bash_rc file as:



alias abaquscae="XLIB_SKIP_ARGB_VISUALS=1 abaqus cae"



Everything worked perfectly fine, as the alias runs the software. Being a lazy champ, I thought of creating a Cairo-dock launcher for this. So I entered abaquscae in the box "command to launch on click" and checked "Run in a terminal". However to my dismay, upon click the launcher it gave an error::



There was an error creating the child process for this terminal
Failed to execute child process "abaquscae" (No such file or directory)


Consequently I wrote a small bash script file "abaquscae.sh":



#!/bin/sh
"XLIB_SKIP_ARGB_VISUALS=1 abaqus cae"


and saved in, made it executable and upon running it in bash shell I again got the similar error, i.e. :



./abaquscae.sh: 2: ./abaquscae.sh: XLIB_SKIP_ARGB_VISUALS=1 abaqus cae: not found 


Now I am totally lost, I have tried many tricks e.g.

1- removing commas in the bash script,

2- making it dos2unix,

3- using full path to the executable

but this script is not running through bash terminal.



PROBLEM:



The command (as well as its alias) are work fine in the bash terminal, however when they are run through some other channel (e.g. scripts/launchers) the terminal miserably fails to recognize them :( ..



If any expert has advice/information about how to solve this problem, please share. I will be very thankful.


More From » launcher

 Answers
4

I think the script should be like this:



#!/bin/bash
XLIB_SKIP_ARGB_VISUALS=1 /opt/softwaresname/abaqus cae


You can also create the launcher using the following command:



bash -c 'XLIB_SKIP_ARGB_VISUALS=1 /opt/softwaresname/abaqus cae'


Setting environment variables before the executable file name in a command line is a feature of CLI (Command Line Interface) shells. If you put VARIABLE=value /path/to/executable in a launcher, the program that reads the launcher (and effectively launch the executable) will try to find a file named "VARIABLE=value" and, of course, will fail.



That command launches bash, the default user shell in Ubuntu, and tell it to execute (the -c option) the string "XLIB_SKIP_ARGB_VISUALS=1 /opt/softwaresname/abaqus cae", so it will be interpreted like it is when you type that in the CLI.


[#32306] Friday, August 13, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kilusy

Total Points: 171
Total Questions: 110
Total Answers: 128

Location: Cayman Islands
Member since Sat, Dec 5, 2020
3 Years ago
kilusy questions
;