Sponsored Content
Top Forums Shell Programming and Scripting Help for scripting sh / Add user auto Post 302423700 by Helix_87 on Friday 21st of May 2010 06:26:43 PM
Old 05-21-2010
Help for scripting sh / Add user auto

Hi,

have to make a script that adds users and generates encrypted passwords.
When I run the script I have this error message: ". / Autouser.sh: line 29: $ 1: ambiguous redirect"

Code:
 1 #!/bin/sh
  2 #
  3 # Script de création auto d'utilisateur
  4
  5 if [ -e $1 ]
  6  then
  7
  8         while read ligne
  9                 echo $ligne
 10                 do
 11                         prenom= $(echo $ligne | ligne cut -d: f1)
 12                         nom= $(echo $ligne | ligne cut -d: f2)
 13                         login= $prenom"."$nom
 14                         echo $login
 15                         mdp= $(pwgen 4 1)
 16                         echo  $mdp
 17                         mdpcrypt= $(mkpasswd - S $mdp)
 18                         useradd -p $mdpcrypt  $login
 19                         echo "****************************************"
 20                         echo "    Creation des utilisateurs en cours .... "
 21                         echo "          Veuillez patienter "
 22                         echo "****************************************"
 23                         echo $login ":" $mdp >> comptes.txt
 24         done < $1
 25
 26         else
 27                 echo "Erreur : Le fichier n'existe pas"
 28
 29 fi

I really searched for a solution and I am a beginner ...
Your help would be welcome

Last edited by Helix_87; 05-21-2010 at 07:33 PM.. Reason: Please use code tags
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

freebsd auto login user at boot / i'm stuck

I run freebsd 4.8 and try to find the way or 'a' way to log in a certain user i created automaticaly at pc boot. I have searched the net, the manuals, but found nothing... could anyone please get me going by showing me an example or what file(s) i need to take a look at. i am not working... (6 Replies)
Discussion started by: termiEEE
6 Replies

2. Solaris

Auto Locking user accounts

Hi, I am trying to setup account locking in Solaris 9. I have made the changes in /etc/default/login where RETRIES=5 and SYSLOG_FAILED_LOGINS=5 and in /etc/user_attr I am having: test_user::::lock_after_retries=yes Still I am not able to lock test_user after successive unsuccessful... (1 Reply)
Discussion started by: run_time_error
1 Replies

3. AIX

AIX; Auto clearing of 'too many invalid login attempts by user'

Does anyone have a good script / cron job that handles this? I have looked in smit and see it is clearing this count with: chsec -f /etc/security/lastlog -a "unsuccessful_login_count=0" -s '{userid}' However when I looked around to find ways to automate this I have not found an easy... (0 Replies)
Discussion started by: Keith Johnson
0 Replies

4. Shell Programming and Scripting

auto login to Super User account

i want to write to script which will login to su account without hving user interaction.( i know Super user password) i wrote following script its also able to log into su account. but seesion gets terminates soon. what can be done ??? or is there any other solution. i don't want to use expect... (6 Replies)
Discussion started by: anup13
6 Replies

5. UNIX for Dummies Questions & Answers

scripting for user accounts info in UX

Hi guys, May I know how do I list out in UX for - all existing user accounts; sorted by activated/disabled - primary/sec groups of each user - date when the user accounts are created, - user last logon date - last password change date Anyone had done scripting for these info?... (0 Replies)
Discussion started by: doom10
0 Replies

6. UNIX for Dummies Questions & Answers

Scripting - process and user ids...Help please

Hello all: Working on a job I was asked get a simple script to perform the following task and would like to ask for some help. I'm looking forward to learning more and diving deeper into the World of Open Source servers. I need a script for a Unix server, using as few lines as possible, that... (4 Replies)
Discussion started by: moahten
4 Replies

7. Shell Programming and Scripting

Auto answer option in scripting.

Hi masters, How to get auto answer option in scripting. for example in my script i uses the gpg command , in that beginning it will ask passpharse : ( in that i need to type my passpharase) and once i typed it will ask Use this key anyway? ( for that answer will be yes) for... (1 Reply)
Discussion started by: anishkumarv
1 Replies

8. OS X (Apple)

Scripting User Account Removal

Ok, so I've been looking all over the place for how exactly to do this and I've become so bombarded with information I finally decided I'll pose the question here. I'm not a programmer or anything that hardcore, but if I see things already implemented and working examples I can easily learn and... (17 Replies)
Discussion started by: panacea
17 Replies

9. Red Hat

Auto Increasing Quota for User.

Hi, I would like to know wheather we can increase the quota for particular user automatically? I am having requirement to increase the quota only for 2 days in a week. but that shoule be automatically instead of manualy modification. is it possible? (3 Replies)
Discussion started by: manoj.solaris
3 Replies
script(1)							   User Commands							 script(1)

NAME
script - make record of a terminal session SYNOPSIS
script [-a] [filename] DESCRIPTION
The script utility makes a record of everything printed on your screen. The record is written to filename. If no file name is given, the record is saved in the file typescript. See WARNINGS. The script command forks and creates a sub-shell, according to the value of $SHELL, and records the text from this session. The script ends when the forked shell exits or when Control-d is typed. OPTIONS
The following option is supported: -a Appends the session record to filename, rather than overwriting it. NOTES
script places everything that appears on the screen in filename, including prompts. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5) WARNINGS
script can pose a security risk when used in directories that are writable by other users (for example, /tmp), especially when run by a privileged user, that is, root. Be sure that typescript is not a link before running script. SunOS 5.11 30 Jan 2004 script(1)
All times are GMT -4. The time now is 11:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy