0

I have some commands I would like to run in the following order:

HEADAS=/home/warano/HEASoft/heasoft-6.24/x86_64-pc-linux-gnu-libc2.27
export HEADAS 
alias heainit=". $HEADAS/headas-init.sh" 
heainit
CALDB=/home/warano/NUSTAR/caldb
export CALDB 
source $CALDB/software/tools/caldbinit.sh 

I put all of these in a script called run-nu_tools.sh, but it does not work so I got this output:

./run-nu_tools.sh: line 6: heainit: command not found

However heainit works if one runs everything in the terminal(step by step) so I want to run all at once, do you have any tips?

Wara
  • 304
  • 2
  • 11

1 Answers1

2

The problem is that aliases are not expanded if the shell is not interactive:

ALIASES: Aliases are not expanded when the shell is not interactive unless the expand_aliases shell option is set using shopt.

source: man bash

Add the following to your script:

shopt -s expand_aliases
Community
  • 1
  • 1
kvantour
  • 25,269
  • 4
  • 47
  • 72
  • It does not work. – Wara Nov 12 '18 at 10:57
  • If it doesn't work for you, some part of the prerequisites is wrong. Are you not using Bash after all, perhaps? See also https://stackoverflow.com/questions/5725296/difference-between-sh-and-bash – tripleee Nov 12 '18 at 11:13