How to link sed from /usr/bin/sed to /usr/local/bin/sed?

Hi Guys,
OS:- Solaris 10 64Bit
I have a small query.
On one server a user is facing sed command issue.
He gets error regarding sed for this location

/users/hoy/2999/batch5/bin/internal.sh[69]: /usr/local/bin/sed:  not found

How ever the sed is actually present at this location on server:-

/usr/bin/sed

So I need to know How can I solve this problem?
I guess ln -s will do the trick here but need to know what exactly I need to do here?
And how to check version of sed here on the Server?
Please advise.
Thanks.

Have your looked at internal.sh on line 69 ? Chances are there is a call to /usr/local/bin/sed , wereas on your system it is located in /usr/bin . If so, the script would need to be adjusted..

The person who wrote internal.sh presumably specified /usr/local/bin/sed because the version of sed installed in that location had some feature that was not available in /usr/bin/sed on the system where the script was deployed. If you can find the author of that script, find out from them what version of sed the script needs to work correctly and install it as /usr/local/bin/sed on the server in question. If you can't find the author, but can find out what system was running this script, find out what version of sed is installed in /usr/local/bin on that system.

If you can't find the person that wrote the script and can't figure out which system the script came from, get someone who knows sed to examine the way the script uses options and regular expressions to determine why the author didn't just use /usr/bin/sed. Then, either rewrite the script to use "standard" sed options and BREs or change it to reference a different version of sed on your Solaris System that has the desired features (/usr/xpg4/bin/sed, /usr/gnu/bin/sed, ...).

You could use ln -s to set up a symlink, but that defeats the purpose of /usr/local/bin. If the script can use /usr/bin/sed instead of /usr/local/bin/sed, change the script to just use sed (or explicitly use /usr/bin/sed) rather than /usr/local/bin/sed.

Hi all,

Thanks for reply.

I have downloaded GNU version of sed-4.2.2.tar.gz from this site.

ftp://ftp.gnu.org/gnu/sed

BUt I need to know how to install it.

After doing gunzip I got this in folder:-

-bash-3.2$ ls
ABOUT-NLS       COPYING         INSTALL         NEWS            THANKS          bootstrap       config_h.in     doc             po
AUTHORS         COPYING.DOC     Makefile.am     README          aclocal.m4      bootstrap.conf  configure       lib             sed
BUGS            ChangeLog       Makefile.in     README-alpha    basicdefs.h     build-aux       configure.ac    m4              testsuite
-bash-3.2$
-bash-3.2$ ls
ABOUT-NLS       COPYING         INSTALL         NEWS            THANKS          bootstrap       config_h.in     doc             po
AUTHORS         COPYING.DOC     Makefile.am     README          aclocal.m4      bootstrap.conf  configure       lib             sed
BUGS            ChangeLog       Makefile.in     README-alpha    basicdefs.h     build-aux       configure.ac    m4              testsuite
-bash-3.2$

Need to know how to install it, I also need to make sure that it is installed in /usr/local/bin.

Please advise.

Thanks

If you have a program named gunzip installed, do you also have gsed installed?

When you download software and it includes a file named README , I think it should be obvious that you should start by reading that file. Then, at a minimum, read the files INSTALL , Makefile.am and Makefile.in , ABOUT-NLS , BUGS , and NEWS . Assuming that sed and testsuite are directories, I would also look at the files in them. If you're curious (or paranoid), look at all of the files you downloaded!

Then, if the instructions on what to do to install GNU sed as /usr/local/bin/sed weren't clear, show us the instructions you didn't understand.

1 Like

/usr/bin/gunzip belongs to Solaris since a decade (package SUNWgzip).

1 Like

Redme file has nothing:-

-bash-3.2$ cat README
This is the GNU implementation of sed, the Unix stream editor.
See the NEWS file for a brief summary and the ChangeLog for
more detailed descriptions of changes.
See the file INSTALL for generic compilation and installation
instructions.
See the file BUGS for instructions about reporting bugs.
The file README.boot gives instructions for making a "bootstrap"
version of sed on systems which lack any pre-existing and working
version of sed.
-bash-3.2$

This is what INSTALL file say:-

  On Solaris, don't put `/usr/ucb' early in your `PATH'.  This
directory contains several dysfunctional programs; working variants of
these programs are available in `/usr/bin'.  So, if you need `/usr/ucb'
in your `PATH', put it _after_ `/usr/bin'.
   On Haiku, software installed for all users goes in `/boot/common',
not `/usr/local'.  It is recommended to use the following options:
     ./configure --prefix=/boot/common

As I need to install GNU version of sed in /usr/local/bin
do I need to do :- ./configure --prefix=/usr/local/bin ???
Please advise.
Modifying the script is last option.
By the way is there any site which can give me GNU version of sed in Solaris package format , that would be really nice.
Thanks a lot.

First things first:
Like Don Cragun mentioned, don't you have gsed on your system?
Try which gsed to see if it is there or check if there is /opt/csw/bin/gsed . If so, you could make a symlink from /usr/local/bin/sed to /opt/csw/bin/gsed. A more universal alternative would be to test inside the script if it is in Solaris and then check if gsed is available and use that.

If it is not there are packages on the Solaris companion CD that will install them there.

If you want to compile sed, then you would need to check is gcc is installed on your Solaris system. If so it will probably be in /usr/sfw/bin

If so, follow the instructions in the README file for Solaris. Probably the default is to install in /usr/local (you can check with make -n after you configure ). Maybe all you need is go to the directory with the GNU sed source code and

./configure
make
sudo make install
1 Like

Hi,

I see make at below location at my system:-

/usr/ccs/bin/make
/usr/share/lib/make
/usr/xpg4/bin/make

which make can I use?

this is what I have starting with ma in system:-

mac         mach        magnifier   mail        mailcompat  mailp       mailq       mailstats   mailx       makedev     makeuuid    man
-bash-3.2$ pwd
/users/sed/sed-4.2.2
-bash-3.2$ ls
ABOUT-NLS       COPYING         INSTALL         NEWS            THANKS          bootstrap       config_h.in     doc             po
AUTHORS         COPYING.DOC     Makefile.am     README          aclocal.m4      bootstrap.conf  configure       lib             sed
BUGS            ChangeLog       Makefile.in     README-alpha    basicdefs.h     build-aux       configure.ac    m4              testsuite

This is what I have in my sed folder.

Please advise.

Did you check the other options first?

1 Like

Which options?

If gsed is installed, if you can install the SUN/Oracle supplied version from the companion CD, if gcc is installed ...

/usr/ccs/bin/make and /usr/xpg4/bin/make are identical. (/usr/share/lib/make is a directory.)
There might be /usr/sfw/bin/gmake (GNU make).
And /usr/sfw/bin/gcc .
sfw means "Sun Free Ware" but is no longer free.
A similar role plays /opt/csw . The tool /opt/csw/bin/pkg-get can install/update additional packages from the Internet.

1 Like

And FWIW, if there is a /usr/sfw/bin/gmake, use that instead of /usr/ccs/bin/make. Way too many open source packages rely on GNU extensions to work with older, stricter make versions.