Operating System - HP-UX
1846636 Members
1617 Online
110256 Solutions
New Discussion

Re: problem using sed in swinstall postinstall script

 
SOLVED
Go to solution
Alan Meyer_4
Respected Contributor

problem using sed in swinstall postinstall script

I am creating a SD.package (using swpackage) to make some simple site configuration changes to our machines. One of the changes is to alter the default directory for root from / to /root.

My postinstall script has the following lines:

sed '1s.:/:.:/root:.p' /etc/passwd >/tmp/passwd
mv /tmp/passwd /etc/passwd

When I run this script from a regular shell prompt, it works great. This:

root:*:0:3::/:/sbin/sh

becomes

root:*:0:3::/root:/sbin/sh


But, when I install the SD.package, and the script runs as a postinstall script, this:

root:*:0:3::/:/sbin/sh

becomes

root:*:0:3::/root:/sbin/sh
root:*:0:3::/root:/sbin/sh

In other words, I get 2 lines in the /etc/passwd file.

There are a few other sed commands in the script and the same thing happens for each sed command. I get double the lines in the output file.

Any suggestions?

-Alan Meyer
" I may not be certified, but I am certifiable... "
2 REPLIES 2
Sanjay_6
Honored Contributor
Solution

Re: problem using sed in swinstall postinstall script

Hi,

Do not use the "p" option in the Substitute option with the sed command.

in place of
sed 's/old_string/new_string/p'

use
sed 's/old_string/new_string/'

Hope this helps.

Regds
Alan Meyer_4
Respected Contributor

Re: problem using sed in swinstall postinstall script

That was it, thank you for your tip.

-Alan
" I may not be certified, but I am certifiable... "