PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > to edit PATH
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

to edit PATH

Réponse
 
LinkBack Outils de la discussion
Vieux 20/08/2006, 10h44   #1
virus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut to edit PATH


I'd like to write a script that adds the current directory to the line in .bash_profile.
I'm not too familiar with sed so , is it possible to do this solely from the bash shell, or can someone suggest a script using sed ?


Thanx
GC

  Réponse avec citation
Vieux 20/08/2006, 11h00   #2
Stephan 'smg' Grein
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: to edit PATH

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

virus wrote:
> I'd like to write a script that adds the current directory to the line in .bash_profile.
> I'm not too familiar with sed so , is it possible to do this solely from the bash shell, or can someone suggest a script using sed ?
>
>
> Thanx
> GC
>

Erm:
$(pwd) >> /path/to/.bash_profile

b.r.,
- --
Stephan 'smg' Grein, <stephan at stephan minus rockt dot de>
http://stephangrein.de
GnuPG-Key-ID: 0xF8C275D4
FingerPrint: 5B6F 134A 189B A24D 342B 0961 8D4B 0230 F8C2 75D4
Geek by nature, Linux by choice.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iQIVAwUBROgyuI1LAjD4wnXUAQIs+w//Ywh9XIu9JcL1gRfuqIRTCgMJH9MSnZSZ
MRT6V6845dfUuIsQhaeozvQB+jW3hD96PVmbma4jKptkto4nd0 oUTRSrcIGETalJ
qspDLr8J82UIWX8C4KO5OfHUna3+EwqxV4v8pGPYvj4dKDRN5M G5H7FwCpz/C3M+
Hn9XOrM+25VEy08pscVEvxfTypEO7YqqUVgGLVtW7dbfH51HhL gqjyz9kNWBxu2+
Nd79N0LVT6tKhZirpZJK+2NLeZ8W85uF8ry/0FYh3pDpkBKOCo+1Nc6JI7imZQ06
gumBEVxP+rJc6Fud53BxZI9Dms5Fqg7j1TTbB85GtmxdSfgSKz OEKdPkl8lx6Sp6
DW1yAg3+k/UIq00sUEdLTSXwX4RtgM6XwiU8O8apFgc4lXC7FlQz9k6WlZcQ mjqp
6i87oBpF1WRW+ZMTZp/AuNord898UkPPVuJrVHZKayI1/xX5ECJ/yzXrq3Li/Nx7
Y0QsXwd+XC0E3glwv9lAEaeFIzWN0olxcnUmV+XWxQEpAxB6oT +s8SU6GuvwZTAx
T8axKHprmK47+KTWT7rjcsL3CnH7Ow4gReIhlUA4Nrxtx2phUJ Quh6TUCd6CLhs+
LWF7bbq2RqqOQWP1zUt+lP+MoX0k6okBIwTilEg8kQ1IX6KdGd 54GLqNBrxxmuZL
rdyZ5vgDCyc=
=oMQc
-----END PGP SIGNATURE-----
  Réponse avec citation
Vieux 20/08/2006, 11h17   #3
Chris F.A. Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: to edit PATH

On 2006-08-20, virus wrote:
>


> I'd like to write a script that adds the current directory to the
> line in .bash_profile.


Don't.

While adding the current directory to the PATH is a minor security
risk, it is unnecessary.

> I'm not too familiar with sed so , is it possible to do this solely
> from the bash shell, or can someone suggest a script using sed ?


printf "\nPATH=%s:$PATH\n" "." >> $HOME/.bashrc

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
  Réponse avec citation
Vieux 20/08/2006, 13h50   #4
Bruce Barnett
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: to edit PATH

"virus" <virus@clear.net.nz> writes:

> I'd like to write a script that adds the current directory to the line in .bash_profile.


Bad idea.

It's much safer to learn to type instead of
script
to type
./script

and once it's working, do
mv script ~/bin

(and have ~/bin in your search path)


I used a program called "ls" in my home directory that caught a lot of
people who put "." in their searchpath.


if you INSIST on doing it, make sure it's LAST in the path.



--
Sending unsolicited commercial e-mail to this account incurs a fee of
$500 per message, and acknowledges the legality of this contract.
  Réponse avec citation
Vieux 21/08/2006, 02h02   #5
Jerry Fleming
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: to edit PATH

virus wrote:
> I'd like to write a script that adds the current directory to the line in .bash_profile.
> I'm not too familiar with sed so , is it possible to do this solely from the bash shell, or can someone suggest a script using sed ?
>
>
> Thanx
> GC
>

Do you mean to add the current dir to your search path? Add a dot at the
end of your path in .bashrc is enough. Do not forget to separate path's
with :
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h42.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,20687 seconds with 13 queries