Creating a script requiring a pause for user input


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Creating a script requiring a pause for user input
# 1  
Old 04-29-2013
Linux Creating a script requiring a pause for user input

Hi I'm trying to create a basic script that pauses for user input to verify a file name before generating the output.

I have numerous SSL certificate files which I am trying to determine the expiry date so what I'm trying to do is write a script so that is pauses to request the name of the .pem file and then checks that the file within the directory then runs the command against that file to output the Certificate info. This is what I'm looking for.

Code:
#!/bin/bash
#
# This Script Will Check the Validity Of an SSL CERT

echo  "Please Enter Name Of .pem File To Be Checked [ENTER]:"
echo
echo
          [Checks That File Exists.... 

      if exists then 

  openssl x509 -text -in {name of .pem file user has input}

     if file doesn't exist then

 print .pem file doesn't exist 

exit

Any help on this please
# 2  
Old 04-29-2013
try to use this

Code:
if [ -f $file ]; then
echo "exists"
else
echo "not existing"
fi

# 3  
Old 04-29-2013
Thanks

But I need help on how to script it all so that it will prompt me and take my input to run the command

Code:
openssl x509 -text -in

if the input file doesn't exist then I need it to advise 'File Doesn't Exist' and exit
# 4  
Old 04-29-2013
You can prompt the user with echo or printf, and read text via read VARNAME
# 5  
Old 04-29-2013
Quote:
I need help on how to script it all
so that it will prompt me and take
my input to run the command
Code:
echo -n "Please Enter Name Of .pem File To Be Checked [ENTER]: "
read file

if [ -f "$file" ]; then
  openssl x509 -text -in "$file"
else
  echo "File Doesn't Exist: $file"
  exit # from shell script
fi

This User Gave Thanks to hanson44 For This Post:
# 6  
Old 04-30-2013
Quote:
Originally Posted by hanson44
Code:
echo -n "Please Enter Name Of .pem File To Be Checked [ENTER]: "
read file

if [ -f "$file" ]; then
  openssl x509 -text -in "$file"
else
  echo "File Doesn't Exist: $file"
  exit # from shell script
fi

SmilieThanks Hanson44

This works exactly as I needed ...
Now all I need is to be able to continue to check others without exiting the script every time, so after checking the first one I need a question?

Code:
Do you wish to check another [y/n]
If the answer is 'y'
Then Go Back to Beginning 
Else exit

Can you assist here also ?
# 7  
Old 04-30-2013
Do "man bash" on the command line and inside the manpage search for the "select" builtin command...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help Me. The script should not exit until the user gives an input.

Hi everyone, I'm new here and just a beginner in linux scripting. Just want to ask for help on this one. I am trying to create a script that will accept user input (year-month and user/s). I wanted to have the script to continue running, until the user inputs a DATE and name/s of user/s. ... (2 Replies)
Discussion started by: Helskadi
2 Replies

2. UNIX for Dummies Questions & Answers

Creating a new directory by getting input from user

Hi All, I am really new to Linux.I am trying to write a script for creating a new directory by getting input of folder name from the user.Please help me in this regard. #! /bin/bash echo "Enter name of dir":$filename mkdir -p $filename When executing this I am getting following error ... (13 Replies)
Discussion started by: Pradeep_1990
13 Replies

3. Shell Programming and Scripting

Script interacts with user , based on user input it operates

i have a script which takes input from user, if user gives either Y/y then it should continue, else it should quit by displaying user cancelled. #!/bin/sh echo " Enter your choice to continue y/Y OR n/N to quit " read A if then echo " user requested to continue " ##some commands... (7 Replies)
Discussion started by: only4satish
7 Replies

4. Shell Programming and Scripting

How to take input from user or awk script?

Hi Jim, I have following script,i which i need to take dynamic value . script, nawk -v v1=grep"INT_EUR" $propertifilename | cut -d"=" -F2` -F'~' '{if (NF-1 !=v1) {print "Error in " $0 " at line number "NR" tilde count " N-1}}' $filename In the above script i want to use INT_EUR as a variable... (2 Replies)
Discussion started by: Ganesh Khandare
2 Replies

5. Shell Programming and Scripting

User Input Shell Script

Hello I am trying to create a user input shell scipt. The objective is user should enter the circuit number and the input is saved in a log file. If the user does not enter anything then the question should prompt it until the circuit no. is entered. Can any one please correct the code below.... (3 Replies)
Discussion started by: sureshcisco
3 Replies

6. Shell Programming and Scripting

Creating oracle user and giving him grants using shell script

Hi , I want to write a shell script that can create oracle database user and grants permission to this user. Thanks & Regards, Deepak (4 Replies)
Discussion started by: Deepakjha
4 Replies

7. Shell Programming and Scripting

BASH: Any Way to Get User Input Without Requiring Them to Hit the Enter Key?

I'm working on making a menu system on an HP-UX box with Bash on it. The old menu system presents the users with a standard text menu with numbers to make selections. I'm re-working the system and I would like to provide something more akin to iterative search in Emacs. I have a list of 28... (2 Replies)
Discussion started by: deckard
2 Replies

8. Shell Programming and Scripting

User input for execution of script

Hi, I need to get the user input and execute a particular script based on the input provided. For E.g. When I execute the script say Test.sh it should prompt "For which country I need to execute the script? (US/India)" Based on the input as US or India from the user the execution of... (8 Replies)
Discussion started by: yoursdavinder
8 Replies

9. AIX

script for creating aix user

Hi Guys, I want to create user with a script: user name, user id, primary group, group set, home directory, initial program, password, user information, another user can SU to user. And all the rest is the default. Does anyone already have the script for this? Can you please share it... (8 Replies)
Discussion started by: itik
8 Replies

10. Shell Programming and Scripting

creating unique lists from user input

hi all, I'm trying to resolve a scenario where we prompt the user to enter 1 or more disk names. From there we would run a command on each disk which would give its location. This would allow us to create a list of disks at location A, a list of disks at location B,....etc... Any help... (1 Reply)
Discussion started by: annie
1 Replies
Login or Register to Ask a Question