3

I want to replace some utilities(like telnet) with transparent wrappers(with loggers). At first I used aliases, that worked nicely at the command line but gnome doesn't understand shell aliases so that when people would launch the utilities as the shell for a gnome-terminal profile it would run the actual utility instead of the wrapper.

Then I tried adding new folder with symlinks and prepended it to PATH(security isn't a huge concern plus its a special folder just for these symlinks) in ~/.bashrc but they still run the original(I'm guessing gnome doesn't run .bashrc since it works from the command line). Any ideas where setting path needs to go?

Roman A. Taycher
  • 18,619
  • 19
  • 86
  • 141

4 Answers4

1

Maybe update-alternatives fits your needs?

Lesque
  • 773
  • 8
  • 16
  • I thought update-alternatives was more for managing something already managed by it. If you replace something with a symlink to a wrapper(with ability to switch to a symlink to the real thing via update-alternatives) what happens when the package system wants too update with a new binary It would replace the symlink no? – Roman A. Taycher Jan 22 '12 at 08:25
  • @RomanA.Taycher I think there is no problem if you update your system: For example on my Ubuntu: `/usr/bin/telnet -> /etc/alternatives/telnet` and `/etc/alternatives/telnet -> /usr/bin/telnet.netkit`. So when you update the default telnet package, you update in fact `/usr/bin/telnet.netkit` and when you change `alternatives`, you edit the link `/etc/alternatives/telnet`. – Lesque Jan 22 '12 at 13:46
  • It works on ubuntu. Now if I could just find something something for fedora. – Roman A. Taycher Jan 23 '12 at 08:21
  • And find an answer for setting env variables in GNOME(possibly ~/.profile) – Roman A. Taycher Jan 23 '12 at 09:01
  • @RomanA.Taycher Is update-alternatives available for Fedora? For the env variables in GNOME you could try ~\.xsession. – Lesque Jan 23 '12 at 15:14
  • telnet is not a symlink in fedora, at least fedora 10. – Roman A. Taycher Jan 23 '12 at 15:56
0

I found two ways to do this that seem to work like I want(sourcing scripts for gnome env).

First putting it in ${HOME}/.gnomerc (but I found some places that say you should manually exec gnome session afterwards and others that don't(It seems to work fine without it) and I'm afraid of breaking login.)

Putting it in ~/.profile seems to work so I just

echo 'PATH=~/.symlink_dir/:${PATH}' > ~/.profile

(note that this is ignored by bash if a ~/.bash_profile exists so you may want to manually source it from ~/.bash_profile just in case

echo 'source ~/.profile' >> ~/.bash_profile).

Roman A. Taycher
  • 18,619
  • 19
  • 86
  • 141
-1

If you really want to use your replacement utilities throughout, you could put symlinks to your replacements in /usr/bin/ (or wherever as appropriate) and move the originals to /usr/bin/originals/ (or wherever).

If you do that, you'd better make sure that your wrappers are rock solid though. Depending on what you're replacing, errors might prevent booting, which is generally undesirable.

blahdiblah
  • 33,069
  • 21
  • 98
  • 152
  • I wouldn't change a binary installed by a package unless I was a lot more desperate. For one thing what happens when you run an update? – Roman A. Taycher Jan 17 '12 at 04:47
-1

It might not be what you are asking, but have you tried changing the commands of the launchers from the menu editor.

If you are using Gnome 3 you will have to download the alacarte package.

Jonathan Reyes
  • 94
  • 2
  • 12
  • 1
    This. Why don't you create a wrapper script, put it in /home/you/bin/telnet-wrapper.sh and add a launcher which will launch the script? – Quentin Pradet Jan 23 '12 at 14:45
  • I am using wrapper scripts. The point is to have set PATH for GNOME so that gnome-terminal profiles use the wrappers without effort other running the install/upgrade script. – Roman A. Taycher Mar 01 '12 at 04:49