#!/usr/bin/expect
set full_name [lrange $argv 0 0]
set domain_name [lrange $argv 1 1]
set Organization_name [lrange $argv 2 2]
set Generic_name [lrange $argv 3 3]
spawn openssl req -new -newkey rsa:2048 -nodes -keyout $Generic_name.key -out $Generic_name.csr
expect "]:"
send "cn\r"
expect "]:"
send "$full_name\r"
expect "]:"
send "$full_name\r"
expect "]:"
send "$Organization_name\r"
expect "]:"
send "ops\r"
expect "]:"
send "$domain_name\r"
expect "]:"
send "\r"
expect "]:"
send "\r"
expect "]:"
send "\r"
expect eof