Overwrite bash system command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Overwrite bash system command
# 1  
Old 03-05-2015
Overwrite bash system command

Hello,
The problem I met is the conflict between the default command /usr/bin/sometools, which is an very old version at system setup, and an updated one I have installed in $HOME/download-software/sometools
How do I tell a third program to use the customized sometools instead of the default one? This is related to my other question in this this post, again I do not have root privilege.
I have tried the alias in my~/.bashrc by
Code:
alias sometools="$HOME/download-software/sometools"

also I checked
Code:
$which sometools 
/home/yifangt/download-software/sometools

but the program always uses the old version from /usr/bin/sometools. It seems related to login shell and non-login shell, non/interactive shell etc, but I am still not 100% sure after googling a while (I am not alone with this question!) and want to clarify this confusion here related to current problem. Thanks a lot!
# 2  
Old 03-05-2015
Are you calling the "third program" yourself?

Change your PATH to put the path to your "sometools" first.

If the "third program" is hard-coding the path to "sometools", what can you do?
This User Gave Thanks to Scott For This Post:
# 3  
Old 03-05-2015
The third program (this case is a PERL program) is what I called "soft calling" by:
Code:
$sometools_path=`which sometools`

I got lost with bunch of my alias and other export in my .bashrc.
May I ask in another way, does the third program use sometools by the first match or the last match in the $PATH from my .bashrc?
# 4  
Old 03-05-2015
First. If not found, second, etc.
This User Gave Thanks to Scott For This Post:
# 5  
Old 03-05-2015
Regarding aliases: they are normally only used in interactive shells..

From man bash:
Quote:
Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt
# 6  
Old 03-05-2015
Quote:
Originally Posted by Scrutinizer
Regarding aliases: they are normally only used in interactive shells..

From man bash:
Which is another way for saying "shortcuts for stuff I get bored typing all the time at the command line", "ll" being a good example.
# 7  
Old 03-05-2015
non/interactive shell vs non/login shell

Thank both of you!
Now I'm clear about the precedence of the $PATH in .bashrc for my sometools.
Put that aside, how is the $PATH related to the non/interactive shell and non/login shell. OK, the answer is related to the invoke order of the .bashrc, .profile, .bash_profile, which have to be understood.
1) First, when I start the terminal (regular way to click the terminal icon from the panel, Ubuntu/Mac OS), this is the interactive non login shell(it is bash), right?
2) Conceptually I understand login shell, but what is the example in regular use of terminal with login shell?
3) I started a terminal (as 1) above), then I started screen -S name1, the shell within terminal name1 is an interactive non-login shell. Where is the login shell, or, has the login shell even been invoked?
Maybe I should start another thread.
Thank you again!

Last edited by yifangt; 03-05-2015 at 04:47 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. SCO

Command line overwrite

is there a way to overwrite what I have typed in rather than having to hit enter and re enter the command? SCO UNIX 3.2.4.2 (14 Replies)
Discussion started by: steveo314
14 Replies

2. Shell Programming and Scripting

How to run several bash commands put in bash command line?

How to run several bash commands put in bash command line without needing and requiring a script file. Because I'm actually a windows guy and new here so for illustration is sort of : $ bash "echo ${PATH} & echo have a nice day!" will do output, for example:... (4 Replies)
Discussion started by: abdulbadii
4 Replies

3. Shell Programming and Scripting

Student system BASH script

Hi guys, i'm beginner with Unix, I tried my best, but I Really don't know how to finish it :D. here's my problem : I have to do something like Student system - student's name | subjects | mark |credits. after starting script it will ask you for Student's name, then which subject, then the... (2 Replies)
Discussion started by: PrincMehi
2 Replies

4. Shell Programming and Scripting

Find all bash scripts on system

I want to find all bash scripts on my system. What I have so far is this: find / -type f \( -perm -u=x -o -perm -g=x -o -perm -o=x \) | xargs -I{} head -1 {} |grep bashThis will find all executables, read the first line and diplay it, if it contains "bash". Almost done, but I also need the... (8 Replies)
Discussion started by: Cochise
8 Replies

5. Programming

System Calls using C w/BASH

Hello all, I'm attempting to write a basic application that appends an arbitrary list of txt files to one txt file. So, for example, if the application is run like so: appendFileToFile file1.txt file2.txt file3.txt the system command should, hopefully be, cat >> testfile.txt I'm... (4 Replies)
Discussion started by: whyte_rhyno
4 Replies

6. UNIX for Dummies Questions & Answers

Running set options from the command line and bash command

I'm reading about debugging aids in bash and have come across the set command. It says in my little book that an addition to typing set you can also use them "on the command line when running a script..." and it lists this in a small table: set -o option Command Line... (5 Replies)
Discussion started by: Straitsfan
5 Replies

7. Shell Programming and Scripting

System Command dies even when command gets executed successfully

Hi I have created a perl script & running it using Linux machine. I want my script to die when system command is unsuccessful but script is dying even when system command gets executed successfully. :wall: I am using the command below :- system($cmd) || die "FAILED $!"; print "Hello"; ... (2 Replies)
Discussion started by: Priyanka Gupta
2 Replies

8. Shell Programming and Scripting

Bash As System Script

My main machine is set-up so that I configure the network details (IP etc) by command line. However I'm trying to create an bash script to run those commands upon system startup. Problem I have is that the commands require root access and I want it to be fully automatic. Now I figure I need to... (5 Replies)
Discussion started by: jkraw90
5 Replies

9. Shell Programming and Scripting

sed command to overwrite

Hi, i have a file ver.sql with the following contents , Here i need to put a in the next line of END statment . So iam doing the following D:\>type ver.sql begin ctxsys.driimp.set_value('STOP_WORD','yours'); ctxsys.driimp.set_object('STORAGE','BASIC_STORAGE',2);... (1 Reply)
Discussion started by: mhdmehraj
1 Replies

10. Shell Programming and Scripting

Bash Help: users who are not logged into the system to display

A Newbie here, I am working on a script and am having problems with the else part of the script. I can't get the users who are not logged into the system to display on the screen with their username and the text "The user is not logged in". I am sure it is something simple and stupid, but I... (5 Replies)
Discussion started by: rchirico
5 Replies
Login or Register to Ask a Question