Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2893 connectés 

 


Dernière réponse
Sujet : commande su dans un script shell
matafan Tu dois pouvoir donner le pass en utilisant "expect". Sinon tu peux toujours utiliser sudo.

Votre réponse
Nom d'utilisateur    Pour poster, vous devez être inscrit sur ce forum .... si ce n'est pas le cas, cliquez ici !
Le ton de votre message                        
                       
Votre réponse


[b][i][u][strike][spoiler][fixed][cpp][url][email][img][*]   
 
   [quote]
 

Options

 
Vous avez perdu votre mot de passe ?


Vue Rapide de la discussion
matafan Tu dois pouvoir donner le pass en utilisant "expect". Sinon tu peux toujours utiliser sudo.
bahan

black_lord a écrit :

TU NE PEUX PAS !


 
Ok merci.
 
Bahan, pas de raison de s'énerver :hello:

black_lord TU NE PEUX PAS !
bahan Je dois être aveugle là :(. Car je ne vois toujours pas comment faire le tout en automatique avec un script bash.
 
J'ai toujours une invite qui me demande le password...
 
Bahan, qui ne trouve pas l'option pour ajouter le password :bounce:
 
PS : c'est quoi le mode non-intéractif ? :sweat:
black_lord


SU(1)                                                                                                           SU(1)
 
NAME
       su - Change user ID or become super-user
 
SYNOPSIS
       su [OPTS] [-] [username [ARGS]]
 
DESCRIPTION
       su is used to become another user during a login session.  Invoked without a username, su defaults to becoming
       the super user.  The optional argument - may be used to provide an environment similiar to what the user would
       expect had the user logged in directly.
 
       The  user  will  be prompted for a password, if appropriate.  Invalid passwords will produce an error message.
       All attempts, both valid and invalid, are logged to detect abuses of the system.
 
       An optional command can be executed. This is done by the shell specified in /etc/passwd for  the  target  user
       unless the -s or -m options are used.  Any arguments supplied after the username will be passed to the invoked
       shell (shell must support the -c command line option in order for a command to be passed to it).
 
       Unless the -m or -p options are used, the current environment is passed to the  new  shell  with  alterations.
       The  value of $PATH is reset to /bin:/usr/bin for normal users, or /sbin:/bin:/usr/sbin:/usr/bin for the super
       user.  This may be changed with the ENV_PATH and ENV_SUPATH definitions in /etc/login.defs.  $IFS, if is  set,
       is reset to contain space, tab, and newline.  $USER is set to the name of the target user, $HOME is set to the
       home directory of the target user, and $SHELL is set to the shell of the target user.  When using the -m or -p
       options, the user's environment is not changed.
 
       A  subsystem  login is indicated by the presense of a "*" as the first character of the login shell. The given
       home directory will be used as the root of a new filesystem which the user is actually logged into.
 
OPTIONS
       -      make this a login shell
 
       -c, --commmand=<command>
              pass command to the invoked shell using its -c option
 
       -m, -p, --preserve-environment
              do not reset environment variables, and keep the same shell
 
       -s, --shell=<shell>
              use shell instead of the default in /etc/passwd
 
NOTES
       The -m, -p and -s options are restricted by the target user's shell being listed in /etc/shells. If  it's  not
       listed,  then it's assumed to be a restricted account, a normal su is performed, and those options are ignored
       silently.
 
       A subsystem login is indicated by the presense of a "*" as the first character of the login shell.  The  given
       home directory will be used as the root of a new filesystem which the user is actually logged into.
 
       Much of the behavior of this command can be altered via its pam configuration - see pam(7)
 
CAVEATS
       This version of su has many compilation options, only some of which may be in use at any particular site.
 
Files
       /etc/passwd - user account information
       /etc/shadow - encrypted passwords and age information
       /etc/shells - valid user shells
       $HOME/.profile - initialization script for default shell
 
SEE ALSO
       login(1), sh(1), login.defs(5), shells(5), pam(7)
 
AUTHOR
       Julianne Frances Haugh (jfh@austin.ibm.com)


 
tu vois un mode non-interactif ?

bahan

black_lord a écrit :

man su bourdel


 
Il n'explique pas comment tout faire en une seule ligne. Dans tous les cas, il faut préciser d'abord le login puis le mot de passe ?
 
Bahan

black_lord man su bourdel
bahan

black_lord a écrit :

[:kahyman] su


 
Edit, je me suis mal exprimé : Le su ne me donne aucune indication... Pour indication, je suis sous unix. J'ai même pas le droit aux différentes options :( dans ce f... man  
 
Bahan

black_lord [:kahyman] su
bahan Bonjour.
 
Je souhaiterais changer de user au cours d'un script pour des raisons de droit.
 
J'ai donc fait un script bash, mais je ne sais pas quelle est la commande que je peux utiliser pour changer de user. su ?
 
Ca fait un truc de ce genre là :
su --login=bahan --password=monpass
 
Ou alors cela se construit autrement ?
 
Merci d'avance pour votre aide.
 
Bahan

Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)