running several comands in a bash script [duplicate]
This question already has an answer here:
Alias doesn't work inside a Bash script
2 answers
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?
bash scripting
marked as duplicate by kvantour, tripleee
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 10:57
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Alias doesn't work inside a Bash script
2 answers
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?
bash scripting
marked as duplicate by kvantour, tripleee
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 10:57
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Aliases suck anyway. Use a function.
– tripleee
Nov 12 at 10:57
This does not help at all.
– Wara
Nov 12 at 11:07
Why do you say it does not help? Why do you not want to use a function? Why do you want to use an alias? What happens if you use a function anyway?
– tripleee
Nov 12 at 11:08
add a comment |
This question already has an answer here:
Alias doesn't work inside a Bash script
2 answers
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?
bash scripting
This question already has an answer here:
Alias doesn't work inside a Bash script
2 answers
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?
This question already has an answer here:
Alias doesn't work inside a Bash script
2 answers
bash scripting
bash scripting
asked Nov 12 at 10:40
Wara
586
586
marked as duplicate by kvantour, tripleee
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 10:57
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by kvantour, tripleee
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 10:57
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Aliases suck anyway. Use a function.
– tripleee
Nov 12 at 10:57
This does not help at all.
– Wara
Nov 12 at 11:07
Why do you say it does not help? Why do you not want to use a function? Why do you want to use an alias? What happens if you use a function anyway?
– tripleee
Nov 12 at 11:08
add a comment |
Aliases suck anyway. Use a function.
– tripleee
Nov 12 at 10:57
This does not help at all.
– Wara
Nov 12 at 11:07
Why do you say it does not help? Why do you not want to use a function? Why do you want to use an alias? What happens if you use a function anyway?
– tripleee
Nov 12 at 11:08
Aliases suck anyway. Use a function.
– tripleee
Nov 12 at 10:57
Aliases suck anyway. Use a function.
– tripleee
Nov 12 at 10:57
This does not help at all.
– Wara
Nov 12 at 11:07
This does not help at all.
– Wara
Nov 12 at 11:07
Why do you say it does not help? Why do you not want to use a function? Why do you want to use an alias? What happens if you use a function anyway?
– tripleee
Nov 12 at 11:08
Why do you say it does not help? Why do you not want to use a function? Why do you want to use an alias? What happens if you use a function anyway?
– tripleee
Nov 12 at 11:08
add a comment |
1 Answer
1
active
oldest
votes
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 usingshopt
.
source:
man bash
Add the following to your script:
shopt -s expand_aliases
It does not work.
– Wara
Nov 12 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 stackoverflow.com/questions/5725296/…
– tripleee
Nov 12 at 11:13
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 usingshopt
.
source:
man bash
Add the following to your script:
shopt -s expand_aliases
It does not work.
– Wara
Nov 12 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 stackoverflow.com/questions/5725296/…
– tripleee
Nov 12 at 11:13
add a comment |
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 usingshopt
.
source:
man bash
Add the following to your script:
shopt -s expand_aliases
It does not work.
– Wara
Nov 12 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 stackoverflow.com/questions/5725296/…
– tripleee
Nov 12 at 11:13
add a comment |
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 usingshopt
.
source:
man bash
Add the following to your script:
shopt -s expand_aliases
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 usingshopt
.
source:
man bash
Add the following to your script:
shopt -s expand_aliases
edited Nov 12 at 10:51
answered Nov 12 at 10:46
kvantour
7,89331129
7,89331129
It does not work.
– Wara
Nov 12 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 stackoverflow.com/questions/5725296/…
– tripleee
Nov 12 at 11:13
add a comment |
It does not work.
– Wara
Nov 12 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 stackoverflow.com/questions/5725296/…
– tripleee
Nov 12 at 11:13
It does not work.
– Wara
Nov 12 at 10:57
It does not work.
– Wara
Nov 12 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 stackoverflow.com/questions/5725296/…
– tripleee
Nov 12 at 11:13
If it doesn't work for you, some part of the prerequisites is wrong. Are you not using Bash after all, perhaps? See also stackoverflow.com/questions/5725296/…
– tripleee
Nov 12 at 11:13
add a comment |
Aliases suck anyway. Use a function.
– tripleee
Nov 12 at 10:57
This does not help at all.
– Wara
Nov 12 at 11:07
Why do you say it does not help? Why do you not want to use a function? Why do you want to use an alias? What happens if you use a function anyway?
– tripleee
Nov 12 at 11:08