replace shell (sh)


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers replace shell (sh)
# 1  
Old 09-08-2006
replace shell (sh)

Hi,

I need to replace the old "sh" binaries with a new binary.
what could be the steps for the same.
some details:
===============
root@mymachine// $ find / -name sh -print
/usr/bin/sh
/usr/bin/posix/sh
/usr/newconfig/etc/mail/cf/sh
/var/jail/wp_internet/usr/bin/sh
/var/jail/wp_intranet/usr/bin/sh
/sbin/sh

root@mymachine// $ which sh
/usr/bin/sh

In the .profile the PATH is set to :
PATH=/usr/sbin:$PATH:/sbin:/home/root

contents of /etc/passwd file:
oot::0:3::/:/sbin/sh <=======

Thanks,
amit
# 2  
Old 09-08-2006
What OS are you using? Don't fiddle with 'sh' unless you absolutely *have* to. A broken sh can render a system unbootable.

That said, if you just have the binaries, you can take a copy of the existing sh and overwrite with your new shell. If you are compiling from source, the taking copy bit still applies.
# 3  
Old 09-08-2006
Hi,

I'm using HP-UX.
The process i followed was as follows:
1: kill all the instance of "sh" except one.
2: # bash
3: copy the new sh <new_sh> to /bin/ directory
# cp /mydir/<newsh> /bin/
# mv /bin/<newsh> /bin/sh
4: then rename the sh in /sbin directory to something else. let it be <sh_old>
# mv /sbin/sh_old /sbin/sh_veryold
# cp /mydir/<newsh> /sbin/
# mv /sbin/newsh /sbin/sh
5: Logout from the machine.

now even though there is a "sh" in /sbin/ and in /bin, the machine getty could not find these new binaries and failed to open a session for the user.

let me know if there is a better work around for this.
and how can i find the version of "sh" on HP-ux machine.(for linux it is # sh --version)

Thanks,
Amit
# 4  
Old 09-08-2006
For linux, it is actually bash and not sh. sh is a link to bash.

Also, what error did it give? Just "gave an error" does absolutely nothing toward describing the actual error.

Another thing, you cannot just replace /sbin/sh with the same binary as /bin/sh. They are two very different things. The /sbin/sh binary is statically linked (it uses no external libraries). This is helpful if your /usr partition ever gets corrupted and cannot be mounted during boot. If your /sbin/sh is also dynamically linked, if /usr does not mount, you are, in effect, screwed.

So, know what you are doing before you replace sh with your own binary. Remember that sh is used by the system rc scripts during boot. Your new sh better do all that the old one did.
# 5  
Old 09-08-2006
Why, exactly, are you trying to do this? I'm wondering if you are just trying to do something in a dangerous way that can easily be done some other way, e.g. creating an alias, upgrading sh, creating symbolic links, etc.
# 6  
Old 09-12-2006
Hi blowtorch,

Thanks for the input,
how can i prevent the dynamic linking of /sbin/sh ?

Thanks and regards,
amit
# 7  
Old 09-12-2006
You have to use a version that isn't dynamically linked.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace character in shell scripting

Hi, I need to replace the space " " with underscore "_" using shell scripting. The data are inside the text file. Is there are any simple code to that.? (3 Replies)
Discussion started by: gopishrine
3 Replies

2. Shell Programming and Scripting

Replace with shell variable in awk

Hi, Probably this is a out of scope of the thread. I have a requirement as below I have a file with below content CMD //DS > testfile I have to replace //DS with a value which is assigned to a variable outside using awk gsub. For example var=TEST I expect an output as CMD TEST... (1 Reply)
Discussion started by: Ratheesh Nair
1 Replies

3. Shell Programming and Scripting

Search and replace in shell

I have a server.xml in about 50 instances of JBOSS servers which has the following line <Engine defaultHost="localhost" name="jboss.web"> I need to append something into this line based on the hostname . For example hostname abcdprod40j.corp.abc.net <Engine defaultHost="localhost"... (1 Reply)
Discussion started by: gubbu
1 Replies

4. Shell Programming and Scripting

Find and Replace in Shell script

Friends, I have more than 1000 lines in text file which needs to be converted as UPPERCASE by adding _ com.sun.url=www.sun.com com.ssl.port=808 com.ui.path=/apps/ssi Expected output com.sun.url=_COM.SUN.URL_ com.ssl.port=_COM.SSL.PORT_ com.ui.path=_COM.UI.PATH_ Thanks in... (4 Replies)
Discussion started by: baluchen
4 Replies

5. Shell Programming and Scripting

Shell - Replace

Hello , I am trying to replace a pattern in shell script , basically there is a file with the list of tables like A.DAT B.DAT C.DAT .. I will need to replace a prefix for the list TESTA.DAT TESTB.DAT TESTC.DAT Do I need to use <tr> or sed , I am not sure whether I need to... (4 Replies)
Discussion started by: Shanks
4 Replies

6. Shell Programming and Scripting

how to replace a string in the last shell command

for example the last command i run is: tail -f 2010123114_mta2.wmwm.com_postfix-MDAD.log | grep XXXX and i want to raplace '2010123114' with '2010123115', and i don't want to go back to the position and delete 4 and add 5 is there a way to replace a string? like !!//123114/123115 or... (1 Reply)
Discussion started by: wljackhero
1 Replies

7. Shell Programming and Scripting

Shell Script to replace text

I need a little help with a shell script. I want to be able to specify parameters so that the script searches multiple files (specified as parameters) and only modifies the file if it finds the string of text. For the files it doesn't find the string of text within, it should leave it alone. ... (4 Replies)
Discussion started by: joebaber
4 Replies

8. Shell Programming and Scripting

Replace xml values -- Shell --

Hello all, I try to create a bash script but till now without any positiv results. The script should replace different variables in a text file with the right xml values Look at the following xml file: file.xml =================================== <?xml version="1.0"... (14 Replies)
Discussion started by: research3
14 Replies

9. UNIX for Advanced & Expert Users

find a shell and replace the line

I need a shell which makes a search of an UNIX script and them modifies. :confused: vi $(grep -l 5 $(find . -name 'vellon.bcf' -print)) (1 Reply)
Discussion started by: jvellon
1 Replies

10. UNIX for Dummies Questions & Answers

replace a value with another in shell script

hai everybody, i am new to scripting,i have to replace a value with another value ina script...both the values i have got in two seperate variables...can anyone give me the syntax how to do this in a shell script... ie. e1=$5,e2=$6 v2=$1,v3=$7 now i want to... (2 Replies)
Discussion started by: Babu
2 Replies
Login or Register to Ask a Question