Sponsored Content
Top Forums Shell Programming and Scripting How to take input from the user from the command line and execute commands basedon that? Post 302649707 by muraliinfy04 on Friday 1st of June 2012 02:37:33 AM
Old 06-01-2012
How to take input from the user from the command line and execute commands basedon that?

Hi,
I am using solaris 10 and bash shell.Script execution follows below.Initially it will check whether a directory exists or not if does not exist it will create it.(This I have completed)

Second step:I have four users say user1,user2,user3,user4.Script should prompt for the user id and password.then user needs to input the userid and password.That user id should lie with in the above 4 users.if it is other than the mentioned one it should say invalid user.based on the userid and password it will be executing SVN commands(I am fine with SVN commands)

only problem here is how to take the userid and password from the user in middle of script execution.based on that script should continue the execution.

I have tried this.
Code:
[echo "Please enter userid"
read userid
if [ "$userid" = "$user1" ] || [ "$userid" = "$user2" ] || [ "$userid" = "user3" ] || [ "$userid" = "user4" ]
then
cd /export/home/mvaddadi/
svn checkout  --username $userid https://scm-coconet.com/svn/repos/vo...ordgen/current
else
echo "invalid id"
fi]


But it is not working.I believe read is not working properly.Thanks in Advance for your inputs.

Last edited by muraliinfy04; 06-01-2012 at 03:44 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can Xargs execute multiple commands of evry input file

Hello , I am trying to print the footer of evry file in the given directory with xargs command like follows ls -1 | xargs -I {} gzcat {} | tail -1 now problem with this is only last file foooter is getting printed as " | tail -1 " is getting executed for the last file. I know this can... (4 Replies)
Discussion started by: nilesrex
4 Replies

2. Shell Programming and Scripting

How to restrict the number of commands user can execute

Hi all, Is there a way to prevent users from being able to execute commands less a select few? For instance, I wish to allow the user to be only able to execute 1 command, which is exec a.sh. He should not be able to do simple stuff such as ls, cd, rm, cat, etc. Can this be achieved? ... (1 Reply)
Discussion started by: rockysfr
1 Replies

3. Shell Programming and Scripting

root user command in shell script execute as normal user

Hi All I have written one shell script for GPRS route add is given below named GPRSRouteSet.sh URL="www.google.com" VBURL="10.5.2.211" echo "Setting route for $URL for GPRS" URL_Address=`nslookup $URL|grep Address:|grep -v "#"|awk -F " " '{print $2}'|head -1` echo "Executing ... (3 Replies)
Discussion started by: mnmonu
3 Replies

4. Shell Programming and Scripting

Execute commands to specific folder from input file

Hi, I have one text file input.txt, which has folders path as follows: /home/user/automate/abc /home/user/automate/abc/xyz /home/user/automate/test /home/user/automate/test2 /home/user/automate/test2/abc/Main In those folders i have .svn folder. 1) First i want to remove .svn like rm... (5 Replies)
Discussion started by: dragon.1431
5 Replies

5. Shell Programming and Scripting

Command to execute commands one after other

I am writng a script in which there is an installation file.The installer runs good. But after the installer command there are some files and commands which are based on those installed files. Now problem is the commands get executed before the installer is totally installed. So is there any... (5 Replies)
Discussion started by: sriki32
5 Replies

6. Shell Programming and Scripting

Command line user input validation

Hi guys, I have a piece of snippet below which asks the user to input some numbers if isDatasubEnabled && isReconEnabled; then echo "1 = CGT, 2 = Subscriber, 3 = Order Monitor, 4 = Revaluations, 5 = Reconciliation, 6 = All, 7 = Exit" elif isDatasubEnabled &&... (4 Replies)
Discussion started by: pyscho
4 Replies

7. Shell Programming and Scripting

Script for login to servers with user name and password and execute commands

I am having the 15 servers which need to do the monitoring Hi I need a shell script, By which i can log in to multiple servers and execute the commands.. I need to specify the username and password in the scripts. Please help me to write the script so that it can login with username and... (5 Replies)
Discussion started by: nandan8a
5 Replies

8. Shell Programming and Scripting

Reading ls -l output line by line awk the user name and su user to run commands

Using ksh on AIX what I am trying to do is to read the ls -l output from a file in a do while loop line by line. Extract the user name(3rd field) and the directory/file name(9th field) using awk and save them into variables. su -c to the user and change directory/file permisions to 777. Script I... (13 Replies)
Discussion started by: zubairom
13 Replies

9. Shell Programming and Scripting

Execute a command with root user

i m logged in with user1 id. i wish to execute the below as root user for which i tried several commands but all of them fail. sudo 'cat /tmp/tmp.file >>/etc/logger' Password: sudo: cat /tmp/tmp.file >>/etc/logger: command not found sudo cat /tmp/tmp.file >>/etc/logger bash:... (5 Replies)
Discussion started by: mohtashims
5 Replies

10. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies
SIVTEST(1)						      General Commands Manual							SIVTEST(1)

 *

NAME
sivtest - interactive MANAGESIEVE test program SYNOPSIS
sivtest [ -t keyfile ] [ -p port ] [ -m mechanism ] [ -a userid ] [ -u userid ] [ -k num ] [ -l num ] [ -r realm ] [ -f file ] [ -n num ] [ -c ] [ -i ] [ -o option=value ] [ -v ] hostname DESCRIPTION
sivtest is a utility that allows you to authenticate to a MANAGESIEVE server and interactively issue commands to it. Once authenticated you may issue any MANAGESIEVE command by simply typing it in. It is capable of multiple SASL authentication mechanisms and handles encryption layers transparently. This utility is often used for testing the operation of a timsieved server. Also those developing MANAGESIEVE clients find it useful. OPTIONS
-t keyfile Enable TLS. keyfile contains the TLS public and private keys. Specify "" to negotiate a TLS encryption layer but not use TLS authentication. -p port Port to connect to. If left off this defaults to sieve as defined in /etc/services. -m mechanism Force sivtest to use mechanism for authentication. If not specified the strongest authentication mechanism supported by the server is chosen. -a userid Userid to use for authentication; defaults to the current user. This is the userid whose password or credentials will be presented to the server for verification. -u userid Userid to use for authorization; defaults to the current user. This is the userid whose identity will be assumed after authentica- tion. NOTE: This is only used with SASL mechanisms that allow proxying (e.g. PLAIN, DIGEST-MD5). -k num Minimum protection layer required. -l num Maximum protection layer to use (0=none; 1=integrity; etc). For example if you are using the KERBEROS_V4 authentication mechanism specifying 0 will force sivtest to not use any layer and specifying 1 will force it to use the integrity layer. By default the max- imum supported protection layer will be used. -r realm Specify the realm to use. Certain authentication mechanisms (e.g. DIGEST-MD5) may require one to specify the realm. -f file Pipe file into connection after authentication. -n num Number of authentication attempts; default = 1. The client will attempt to do SSL/TLS session reuse and/or fast reauth (e.g. DIGEST-MD5), if possible. -c Enable challenge prompt callbacks. This will cause the OTP mechanism to ask for the the one-time password instead of the secret pass-phrase (library generates the correct response). -i Don't send an initial client response for SASL mechanisms, even if the protocol supports it. -o option=value Set the SASL option to value. -v Verbose. Print out more information than usual. SEE ALSO
timsieved(8) CMU
Project Cyrus SIVTEST(1)
All times are GMT -4. The time now is 01:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy