Automatically enter input in command line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automatically enter input in command line
# 8  
Old 10-26-2016
Hi,
./build-key is a script shell that use openssl...
you can copy and modify this script to add option -subj to fill your fields.
in man req :
Quote:
-subj arg
Replaces subject field of input request with specified data and outputs modified request. The arg must be formatted as
/type0=value0/type1=value1/type2=..., characters may be escaped by \ (backslash), no spaces are skipped.
You can too modify config file to set param prompt at 'no':
Quote:
prompt
if set to the value no this disables prompting of certificate fields and just takes values from the config file directly. It also changes the
expected format of the distinguished_name and attributes sections.
Regards.
# 9  
Old 10-27-2016
Thanks for your reply, but I want to avoid to edit the script, I look for another solution in my side and if someone has another way, with peasure Smilie
# 10  
Old 10-27-2016
You could make your system less secure by installing the expect brute force hacking tool, learn its new programming language, and use it to fool openssl into believing it's talking to a real terminal.

Or you can make a minor edit to ./build-key so you can feed in a noninteractive argument the way openssl is designed to handle them.

Your choice.
# 11  
Old 10-28-2016
May be a trick if your script build_key use the variable KEY_CONFIG:
Before to launch the script build_key, just add 2 lines:
Code:
KEY_CONFIG="/etc/openvpn/easy-rsa/openssl-1.0.0.cnf -batch"
export KEY_CONFIG

This trick set -batch option to openssl commande that use this variable without to modify build_key script.

Regards.

---------- Post updated at 03:33 PM ---------- Previous update was at 12:21 AM ----------

another idea that depends on how the build-key script invokes the openssl command.
If it is invoked via the PATH, just in this case create a script called "openssl" that will invoke the real openssl with an additional parameter (-batch) for example.
In your script:
Code:
PATH=path_of_your_script_openssl:$PATH
build-key "$username"
PATH=${PATH#*:}

And script openssl might look like:
Code:
#!/bin/bash
PATH=${PATH#*:}
openssl $@ -batch
exit $?

Regards.

Last edited by disedorgue; 10-27-2016 at 08:40 PM.. Reason: Explain no need to modify build_key script
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Expect command to send the user input enter or ctrl+c

Hey All, I am writing one script using expect, that script which is used in spawn will accepts only 1. Enter 2. Ctrl+c Press Control-C to exit, Enter to proceed. Could some one share some thoughts to send the above user inputs in linux expect block ? Thanks, Sam (0 Replies)
Discussion started by: SCHITIMA
0 Replies

2. Shell Programming and Scripting

How to automatically enter password in a script?

Hi I'm working with AIX 6.1 I would like to ssh to a server without entering password ( to monitor something) but there's no way to do that by authentication keys, so I need to write a script which can ssh to that server without entering password ( no need to hide passsword in the script, just an... (9 Replies)
Discussion started by: bobochacha29
9 Replies

3. Shell Programming and Scripting

Loop logic, enter into respective IF as per enter input file name

have three big data file, however I just need to see the mentioned below one line form the all the file which has SERVER_CONNECTION Value File 1 export SERVER_CONNECTION=//dvlna002:10001/SmartServer File2 export SERVER_CONNECTION=///SmartServer File3 export... (1 Reply)
Discussion started by: Nsharma3006
1 Replies

4. Shell Programming and Scripting

function terminating if i give input as space or no input and enter

HI i have written a script to ask input from the user. this script should promote the user for y/n input. if user enters anyother input then y/n the script promotes him again. this below code is working fine for all the cases. except for space and enter " if i give space and enter it is... (2 Replies)
Discussion started by: BHASKARREDDY006
2 Replies

5. Shell Programming and Scripting

Enter an input and reference another line in ksh script

Hi I have a file like so: Code: Frank Peter Tony Robert Mike 1 2 3 4 5 5 4 2 3 1 4 3 1 5 2 My out should look like this: Peter Tony Mike and so on.... I have the first part done to ask the user to... (8 Replies)
Discussion started by: bombcan1
8 Replies

6. Shell Programming and Scripting

using read to enter the input at runtime

Hi I am stucked in the below script .I want to input with yes/no from the user and then execute the code inside if but it is not working .I just need the logic as where I am wrong so that i can use the same in my work . then echo "Hi All" fi ]. Please suugest . (4 Replies)
Discussion started by: mani_isha
4 Replies

7. Shell Programming and Scripting

Script to automatically enter a password

I need to retrieve thousands of lines of information from hundreds of nodes. Each node requires a passowrd in order to retrieve the information. Fortunately, the password is the same for each one of them. So I am trying to come up with a script that would allow me to include the password so I can... (0 Replies)
Discussion started by: Ernst
0 Replies

8. UNIX for Dummies Questions & Answers

how to enter hardcoded password automatically

In the script i am passing a command from script which is called from cron. When this command is called from cron the unix prompt asks for password. Can we automatically enter the password when promted(if the password is hardcoded in script)?? Please let me know how to enter the password... (4 Replies)
Discussion started by: abhi_n123
4 Replies

9. Shell Programming and Scripting

How to enter a password in the script automatically when prompted?

Hi Friends, We need to create a script which will invoke a command with diffrent parameters. The command invoked needs the password. So how automatically we can enter password in the script to the command? example.: #!/bin/ksh for par in `cat parfile` do # Here is the main command... (1 Reply)
Discussion started by: sourabhsharma
1 Replies

10. Shell Programming and Scripting

How to enter if-then condition on command prompt/line ?

Hi I have some trouble entering if-then condition in a single line on a command prompt in csh. Could someone show how does one do that ? eg: source .cshrc; cd $dir; pwd; test -d $backup_dir; if then mkdir -p ${backup_dir}; echo inside loop; fi; echo outside loop; mv -f... (3 Replies)
Discussion started by: mpc8250
3 Replies
Login or Register to Ask a Question