Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 \opt\softwaresname 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.

share|improve this question
    
First of all I don't think the neither the dock's or the script's shell uses your bash profile. I think the best thing to do is to put your executable script in one of the standard binary folders (like /usr/local/bin for example), and make sure to put the correct permissions and ownership. –  oaskamay Mar 8 '13 at 14:01
    
I have placed the script in /usr/local/bin/ , made it executable, and have set the permissions, but the error persists: /usr/local/bin/abaquscae.sh: 2: /usr/local/bin/abaquscae.sh: XLIB_SKIP_ARGB_VISUALS=1 abaqus cae: not found –  Mubeen Shahid Mar 8 '13 at 14:50
    
Okay, what happens when you remove XLIB_SKIP_ARGB_VISUALS=1 from the script (i.e. just running abaqus cae like that from the script)? If it still complains about abaqus, make a symlink to it and put it in /usr/local/bin/ with the right permissions. Good luck! –  oaskamay Mar 8 '13 at 15:05
    
"1- removing commas in the bash script,", did you mean removing quotes? That line really shoudn't be quoted. –  Eric Carvalho Mar 8 '13 at 16:05

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
the fist option didnt work , however the 2nd option i.e. the launcher command bash -c 'XLIB_SKIP_ARGB_VISUALS=1 /opt/softwaresname/abaqus cae' worked like a charm .. TONS OF THANKS !! –  Mubeen Shahid Mar 8 '13 at 16:47
    
I am really happy that the launcher is working now .. Would you please explain the science behind this method? –  Mubeen Shahid Mar 8 '13 at 16:50
    
@MubeenShahid Answer updated. –  Eric Carvalho Mar 8 '13 at 17:08
    
You should still put a symlink to /opt/softwaresname/abaqus in /usr/local/bin/ –  oaskamay Mar 8 '13 at 19:42
    
@oaskamay: yes I had placed the symlink as you mentioned in the comment. Thanks for adding this valuable information :) –  Mubeen Shahid Mar 8 '13 at 19:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.