I have a program in which the user enters the login credentials and if they fail 3 times in a row, they are locked out of the program (PS. How do I do that? Just "exit"?)
Here's what I have:
I'm getting a syntax error on line 9 due to the Else, not sure why.
I think the for loop will work, I'm not sure. I can't really test it properly because of this if statement not working
Probably best to just make the script readable/executable by admin user.
Putting password in the script is not at all secure as user needs to be able to read it to execute an so can just cat/view the script and note down the password.
Thanks sea, that worked.
Question though, with this, instead of it breaking the loop, it plays the message 3 times that the password/username is wrong. Basically it doesn't let the user try again.
I think this is because it isn't changing the values of PASSVAR and USERVAR. How would I reset their values and let the user try again? I have USERVAR = "" and the same for passvar, but I don't think that works. Or rather, it works, and then the program checks for the USERVAR/PASSVAR again, and they are blank. Whilst blank, it still checks them as wrong and shows that it is wrong.
Not sure what to do here
Edit: Even when the user puts in the correct credentials, it still says it is wrong.
Note: the proper syntax for numerical comparison in sh is if [ "$TRY" -eq 4 ].
Also read -p and read -s are bash syntax, but the shebang says #!/bin/sh. So if you want to use that syntax, you need to change the shebang to #!/bin/bash, to ensure the script runs with the proper shell.
In order to repeatedly ask for user name and password, you would need to make the read statements part of your loop, for example:
--
If you are switching to bash syntax you could also use:
--
I agree with Chubler, that putting a password in a script is not a secure way to go about..
This User Gave Thanks to Scrutinizer For This Post:
I am writing a shell script with 2 run time arguments. During the execution if i got any error, then it needs to redirected to a error file and in console. Also both error and output to be redirected to a log file. But i am facing the below error.
#! /bin/sh
errExit ()
{
errMsg=`cat... (1 Reply)
I have two servers with a fresh install of Solaris 11, and having problems when doing rpcinfo between them. There is no firewall involved, so everything should theoretically be getting through. Does anyone have any ideas? I did a lot of Google searches, and haven't found a working solution yet.
... (2 Replies)
what is this error log = hda: irq timeout: error=0x00 and how to solve?
every day upon checking the logs i see this error.
hda: irq timeout: error=0x00
hda: irq timeout: error=0x00
hda: irq timeout: error=0x00
hda: irq timeout: error=0x00
hw_client: segfault at 0000000000000046 rip... (3 Replies)
im kinda new to shell scripting so i need some help
i try to run this script and get the error code
> 5 ")syntax error: operand expected (error token is "
the code for the script is
#!/bin/sh
#
# script to see if the given value is correct
#
# Define errors
ER_AF=86 # Var is... (4 Replies)
Hi - I am getting the error
`Error reading response length from authentication socket'
when I ssh from my cluster to another cluster, and then back to my cluster. It doesn't seem to affect anything, but it's just annoying that it always pops up and tends to confuse new users of the cluster. I... (1 Reply)
Hi Guys.
This is part of my filesystem structure :
Filesystem size used avail capacity Mounted on
/dev/md/dsk/d0 47G 5.2G 42G 12% /
/devices 0K 0K 0K 0% /devices
ctfs 0K 0K 0K 0% ... (2 Replies)
--------------------------------------------------------------------------------
Hello, help me please.
I am trying to create a mksysb bakup using nim. I am geting this error, how to correct it ? :
Command : failed stdout: yes stderr: no... (9 Replies)
I encounters a VSIFAX related error:
vfxstat: Cannot login to server on rsac3: Connect error to host 172.16.1.45: Invalid argument
It started happening last night with a core dump. Then we can't start VSIFAX again.
I am runing VSI-FAX 4.2 on AIX box (0 Replies)
hi there
i write one awk script file in shell programing
the code is related to dd/mm/yy to month, day year format
but i get an error
please can anybody help me out in this problem ??????
i give my code here including error
awk `
# date-month -- convert mm/dd/yy to month day,... (2 Replies)
Hey guys, need some help. Running AIX Version 5.2 and one of our cron jobs is writing errors to a log file. Any ideas on the following error message.
Error: Internal system error: Unable to initialize standard output file
I'm guessing more info might be needed, so let me know.
Thanks (2 Replies)