$PWD sur unix
royinfo
-
dubcek Messages postés 19032 Date d'inscription Statut Contributeur Dernière intervention -
dubcek Messages postés 19032 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
Je suis un p'tit nouveau sur Unix et j'aimerais redefinir dans mon profile la variable PS1 afin de voir en tout temps le path dans lequel je suis.
Je connecte en temps que ROOT.
j'utilise la commande : PS1="$LOGNAME->$PWD" ;export PS1
lors du Login, le prompt est : root-> il n'affiche pas le repertoire.
si je fais echo de $PWD il est blanc.. pourquoi ?
merci
Je suis un p'tit nouveau sur Unix et j'aimerais redefinir dans mon profile la variable PS1 afin de voir en tout temps le path dans lequel je suis.
Je connecte en temps que ROOT.
j'utilise la commande : PS1="$LOGNAME->$PWD" ;export PS1
lors du Login, le prompt est : root-> il n'affiche pas le repertoire.
si je fais echo de $PWD il est blanc.. pourquoi ?
merci
7 réponses
Salut,
PS1="[\u ->\w] # "Si tu veux que ce soit permanent tu mets ça dans le .bashrc du "root" :
PS1="[\u ->\w] # " export PS1
[tmpfs]$ echo $PS1 [\W]$ [tmpfs]$ PS1="[\u -> \w]$ " [jp -> ~/tmpfs]$ cd /usr/share/ [jp -> /usr/share]$ cd - /home/jp/tmpfs [jp -> ~/tmpfs]$ echo $PS1 [\u -> \w]$ [jp -> ~/tmpfs]$ PS1="[\W]$ " [tmpfs]$ echo $PS1 [\W]$ [tmpfs]$Quel système UNIX utilises-tu ? Quel shell ?
Bonjour a vous et merci de me repondre.
Il s'agit d'un IBM pc server 325 qui doit dater des annees 1980.
Shell ... aucune idee.
lorsque je me connecte avec root je retrouve les fichiers suivants :
Je pensais simplement ajouter ma petite commande dans le fichier .profile
total 6076
-rw------- 1 root sys 52 Apr 23 1998 .Xauthority
-rw-r--r-- 1 root bin 27 Mar 18 1992 .exrc
-r-------- 1 root auth 0 Jan 7 11:47 .lastlogin
-rw------- 1 root root 15 Apr 22 1998 .mailrc
-rw-r--r-- 1 root sys 5 May 8 2007 .mosaicpid
drwxrwxrwx 3 root sys 80 Oct 13 1999 .netscape
drwxr-xr-x 3 bin bin 64 Apr 23 1998 .odtpref
-rw------- 1 root root 984 Jan 7 10:16 .profile
-rw------- 1 root sys 786 Dec 17 14:01 .profile.tmp
-rw-r--r-- 1 root sys 2688 Dec 17 15:29 .roy_demo
-rw-r--r-- 1 root sys 123 Jul 9 2007 .scoadmin.pref
-rw-r--r-- 1 root root 899 Apr 22 1998 .utillist2
drwxr-xr-x 5 root sys 128 Apr 23 1998 .xdt_dir
-rw-r--r-- 1 root sys 0 Apr 23 1998 .xdtsupCheck
Il s'agit d'un IBM pc server 325 qui doit dater des annees 1980.
Shell ... aucune idee.
lorsque je me connecte avec root je retrouve les fichiers suivants :
Je pensais simplement ajouter ma petite commande dans le fichier .profile
total 6076
-rw------- 1 root sys 52 Apr 23 1998 .Xauthority
-rw-r--r-- 1 root bin 27 Mar 18 1992 .exrc
-r-------- 1 root auth 0 Jan 7 11:47 .lastlogin
-rw------- 1 root root 15 Apr 22 1998 .mailrc
-rw-r--r-- 1 root sys 5 May 8 2007 .mosaicpid
drwxrwxrwx 3 root sys 80 Oct 13 1999 .netscape
drwxr-xr-x 3 bin bin 64 Apr 23 1998 .odtpref
-rw------- 1 root root 984 Jan 7 10:16 .profile
-rw------- 1 root sys 786 Dec 17 14:01 .profile.tmp
-rw-r--r-- 1 root sys 2688 Dec 17 15:29 .roy_demo
-rw-r--r-- 1 root sys 123 Jul 9 2007 .scoadmin.pref
-rw-r--r-- 1 root root 899 Apr 22 1998 .utillist2
drwxr-xr-x 5 root sys 128 Apr 23 1998 .xdt_dir
-rw-r--r-- 1 root sys 0 Apr 23 1998 .xdtsupCheck
echo $SHELLPour connaitre ton shell de connexion ou
grep $USER /etc/passwdSinon, affiche le contenu du ".profile".
Il utilise SCO open server..
voici le contenu du .profile de ROOT. Comme vous pouvez voir j'ai redefini PS1 et il ne me donne pas mon path, seulement le LOGNAME. c'est comme si $PWD n'est pas defini nulle part.. si echo de $PWD il me retourne un blanc.
SHELL=/bin/sh
HOME=/
PATH=/bin:/etc:/usr/bin:/tcb/bin
PATH=$PATH:/u/PCA:/u/PCA/bin:/u/PCA/IQ
IQCAP=/u/PCA/IQ/iqcap
IQDATA=/FILES
IQDD=/u/PCA/IQ
# set terminal type
eval `tset -m ansi:${TERM:-ansi} -m :\?${TERM:-ansi} -e -r -s -Q`
export TERM PATH SHELL HOME IQCAP IQDATA IQDD
PS1="$LOGNAME->$PWD" ;export PS1
stty intr "^c"
[ -x /bin/mesg ] && mesg n # if mesg is installed...
root->
voici le contenu du .profile de ROOT. Comme vous pouvez voir j'ai redefini PS1 et il ne me donne pas mon path, seulement le LOGNAME. c'est comme si $PWD n'est pas defini nulle part.. si echo de $PWD il me retourne un blanc.
SHELL=/bin/sh
HOME=/
PATH=/bin:/etc:/usr/bin:/tcb/bin
PATH=$PATH:/u/PCA:/u/PCA/bin:/u/PCA/IQ
IQCAP=/u/PCA/IQ/iqcap
IQDATA=/FILES
IQDD=/u/PCA/IQ
# set terminal type
eval `tset -m ansi:${TERM:-ansi} -m :\?${TERM:-ansi} -e -r -s -Q`
export TERM PATH SHELL HOME IQCAP IQDATA IQDD
PS1="$LOGNAME->$PWD" ;export PS1
stty intr "^c"
[ -x /bin/mesg ] && mesg n # if mesg is installed...
root->
J'ai essaye tous les exemples ci-dessous et rien ne fonctionne..
J'ai modifie le .profile.. ne fonctionne pas .. j'ai cree un .cshrc tel que mentionne et ne fonctionne pas .. j'ai cree un .kshrc tel que mentionne et ne fonctionne pas
Est-ce que quelqu'un a une idee.
merci.
Changing your prompt
A prompt will appear after you have logged into your system. The UNIX system stores this prompt in a variable.
To change your prompt, you reset the value of the prompt variable.
In the Bourne and Korn shells, the prompt variable is called PS1 (prompt string 1). In the C shell, the prompt variable is called prompt.
All three shells have a secondary prompt as well as the main prompt. This secondary prompt is shown when you type a command that makes the shell expect further input.
For example, in the Bourne shell, the secondary prompt is ``>'' by default:
$ for i in *.tut
>
Here, you are saying to the shell ``for every file (i represents every file) ending in .tut ...'' The shell gives you a secondary prompt because it needs more information to complete your command.
In the Bourne and Korn shells, the secondary prompt is stored in the variable PS2 (prompt string 2), which you can reset. You cannot reset the secondary prompt in the C shell. To reset PS2 in sh or ksh, follow the instructions below, substituting PS2 for PS1.
To reset your prompt in the Bourne or Korn shells, type PS1=value where value is the value you want to assign to the prompt variable.
For example, to set your prompt to say ``Yo'', you would add the following line to your .profile or .kshrc:
PS1=Yo
C-shell users would add the following line to their .login:
set prompt=Yo
Q: When I change my prompt, I lose the space between my prompt and where the command line starts. How do I get this back?
A: To keep the space between the prompt and the command line, you need to put a space after your new prompt. To get the shell to notice the space, you need to enclose the whole prompt string in double quotes.
In ksh or sh, add the following line to your .profile:
PS1="Hello friend "
In csh, add the following line to your .login:
set prompt="Hello friend "
Q: How do I get my prompt to show the current directory, like on DOS?
A: In sh, add the following line to your .profile:
nd() { cd $* ; PS1="`pwd` "; }
Now, use the command nd, which you just created, to change to a new directory and display the directory as the prompt.
In ksh, add the following line to your .kshrc:
PS1='$PWD '
In csh, add the following lines to your .cshrc: (You do not need to add the lines that start with #. These are comments.)
# make a command doprompt that sets the prompt to the working directory
alias doprompt 'set prompt="`pwd` "'
# set the prompt the first time around
doprompt
# alias the cd command to change directories and reset the prompt
alias cd 'chdir !* || doprompt'
J'ai modifie le .profile.. ne fonctionne pas .. j'ai cree un .cshrc tel que mentionne et ne fonctionne pas .. j'ai cree un .kshrc tel que mentionne et ne fonctionne pas
Est-ce que quelqu'un a une idee.
merci.
Changing your prompt
A prompt will appear after you have logged into your system. The UNIX system stores this prompt in a variable.
To change your prompt, you reset the value of the prompt variable.
In the Bourne and Korn shells, the prompt variable is called PS1 (prompt string 1). In the C shell, the prompt variable is called prompt.
All three shells have a secondary prompt as well as the main prompt. This secondary prompt is shown when you type a command that makes the shell expect further input.
For example, in the Bourne shell, the secondary prompt is ``>'' by default:
$ for i in *.tut
>
Here, you are saying to the shell ``for every file (i represents every file) ending in .tut ...'' The shell gives you a secondary prompt because it needs more information to complete your command.
In the Bourne and Korn shells, the secondary prompt is stored in the variable PS2 (prompt string 2), which you can reset. You cannot reset the secondary prompt in the C shell. To reset PS2 in sh or ksh, follow the instructions below, substituting PS2 for PS1.
To reset your prompt in the Bourne or Korn shells, type PS1=value where value is the value you want to assign to the prompt variable.
For example, to set your prompt to say ``Yo'', you would add the following line to your .profile or .kshrc:
PS1=Yo
C-shell users would add the following line to their .login:
set prompt=Yo
Q: When I change my prompt, I lose the space between my prompt and where the command line starts. How do I get this back?
A: To keep the space between the prompt and the command line, you need to put a space after your new prompt. To get the shell to notice the space, you need to enclose the whole prompt string in double quotes.
In ksh or sh, add the following line to your .profile:
PS1="Hello friend "
In csh, add the following line to your .login:
set prompt="Hello friend "
Q: How do I get my prompt to show the current directory, like on DOS?
A: In sh, add the following line to your .profile:
nd() { cd $* ; PS1="`pwd` "; }
Now, use the command nd, which you just created, to change to a new directory and display the directory as the prompt.
In ksh, add the following line to your .kshrc:
PS1='$PWD '
In csh, add the following lines to your .cshrc: (You do not need to add the lines that start with #. These are comments.)
# make a command doprompt that sets the prompt to the working directory
alias doprompt 'set prompt="`pwd` "'
# set the prompt the first time around
doprompt
# alias the cd command to change directories and reset the prompt
alias cd 'chdir !* || doprompt'
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Est-ce qu'une fois les changements effectués, tu source ton fichier .profile (ou autre) pour les faire prendre en compte ? (source ~/.profile)
Ou est-ce que tu relances ta session au pire ?
Ou est-ce que tu relances ta session au pire ?
Donnes-nous les résultats des commandes demandées au post #7 et affiche le contenu du fichier "/etc/profile"
hello
en Bourne sh, ceci doit fonctonner
nd() { cd $* ; PS1="`pwd` "; }
je crois me rappeller qu'il faut respecter l'espace entre ; et }, ajouter dans $HOME/.profile
et faire
. $HOME/.profile
il n'y a pas de source et de ~ en Bourne sh
en Bourne sh, ceci doit fonctonner
nd() { cd $* ; PS1="`pwd` "; }
je crois me rappeller qu'il faut respecter l'espace entre ; et }, ajouter dans $HOME/.profile
et faire
. $HOME/.profile
il n'y a pas de source et de ~ en Bourne sh
[\u ->\w] #