[SOLVED] how to use my aliases in a bash script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [SOLVED] how to use my aliases in a bash script
# 1  
Old 11-29-2010
[SOLVED] how to use my aliases in a bash script

Hi,
I confess to be stuck ...
as explained here
Aliases - Bash Reference Manual
I added
Code:
shopt -s expand_aliases

to my script ... but it didn't work.
Later I've read I had to add this at the begning of my my script :
Code:
. ~/.bash_aliases

(of course my aliases are in this file)
but again, the alias command is not found in my script ...

any helps would be welcome.

(please avoid saying I shouldn't use aliases in scripts ... I KNOW IT Smilie )

---------- Post updated at 09:46 PM ---------- Previous update was at 04:52 PM ----------

ok I found my mistake... it was because I used an alias in a variable ... and this doesn't simply work in bash ...

Last edited by xib.be; 11-29-2010 at 04:48 PM.. Reason: solved
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Aliases NOT working inside bash shell script

i have defined a function ln_s() for customizing the ln command in script1.sh. more script1.sh echo "Starting Execution" ./script2.sh echo "End of Execution" ln_s(){ ] && return ln -s "$1" "$2" } My script1.sh executes another script2.sh which has the following entry more script2.sh... (12 Replies)
Discussion started by: mohtashims
12 Replies

2. UNIX for Dummies Questions & Answers

[Solved] Grep in bash script

Hi Experts, I'm writing script to find out last files and its modified date - unfortunately am having problem with the below script. Error message: "grep: sales.txt: No such file or directory" #!/bin/bash var=1 var1=`awk '{n++} END {print n}' sales.txt` while ] do prod=$var... (6 Replies)
Discussion started by: parpaa
6 Replies

3. Shell Programming and Scripting

[Solved] Unable to call a python script from bash

Hi, I am trying to run a python script embedded in bash script. But is throwing me an error. Please help. Script: #!/bin/bash nohup /usr/bin/python /opt/web/http.py & Error: /usr/bin/python: can't open file '/opt/web/http.py': No such file or directory Please help me on this. (6 Replies)
Discussion started by: maddy26615
6 Replies

4. HP-UX

[Solved] Aliases in HP-UX

Hi folks, How can I make an alias in HP-UX? I've tried to add something just like this bye='exit' (as example), the system accepted but when I write bye in the terminal its return with invalid command. When I make such alias in RedHat or Fedora the system accept it right there, what is the... (7 Replies)
Discussion started by: leo_ultra_leo
7 Replies

5. Shell Programming and Scripting

[Solved] Using SSH in bash script

Hello, I am writing a script that has to log in to X number of servers over a full C class range. I am only keyed on a certain number of these servers and this can change from time to time. The part of my script that deals with this is for i in $(cat $server_list); do ssh ... (0 Replies)
Discussion started by: colinireland
0 Replies

6. Shell Programming and Scripting

[Solved] Output in bash script not captured in variable

I'm tring to write down a simple script that would execute a command and wait until it returns a specific result. This is what i did: bjobs_out=`bjobs` while ]; do bjobs_out=`bjobs` sleep 6 done It seems to work until the command 'jobs' return the list of jobs in execution, but... (4 Replies)
Discussion started by: lifedj
4 Replies

7. Shell Programming and Scripting

bash aliases and command chaining with ; (semi-colon)

What am I doing wrong here? Or is this not possible? A bug? alias f='find . >found 2>/dev/null &' f ; sleep 20 ; ls -l -bash: syntax error near unexpected token `;' (2 Replies)
Discussion started by: star_man
2 Replies

8. Shell Programming and Scripting

Using Aliases in a script

Hi all, I have and alias set in .profile like alias ll='ls -la' I am writing a shell script in which i am using "ll" but it gives command not found . Can anyone please tell me how source aliases in the script we write do i need to define it again in every script i write is there any oher... (1 Reply)
Discussion started by: firestar
1 Replies

9. Shell Programming and Scripting

execution of aliases from shell script

Hi I have to execute the commands in .aliases file from a shell script I tried 1.giving the alias directly in shell script 2.Giving the actually "value of alias" in the shell script 3. I tried giving both steps 1 and 2 inside ` quotes Still nothing is working . It says command... (3 Replies)
Discussion started by: ssuresh1999
3 Replies

10. Shell Programming and Scripting

Accessing aliases within a shell script

I am not able to access the aliases in my environment within a Python script. If I pass the alias to os.system(), I get a message saying "sh: x: not found". I've tried sourcing my .bashrc file in the script, but this does not work. I would perfer not to source my or any rc file because this... (9 Replies)
Discussion started by: cooldude
9 Replies
Login or Register to Ask a Question