-2

I have created an .bat file with the following command with a text file which contain "sudo su - oradev2"(C.txt).


cd C:\Users\chakraborty_sayantan\Desktop plink -ssh serverA -l username -pw password -m "C:\Users\username\Desktop\c.txt" -t


The command above completes the first step of logging into a DB and the c.txt file has the instruction to enter into sudo mode. However, post this there is an authentication. Is there a way to automate the step of entering the password? Any thoughts? Procedure to automate

  1. login
  2. password
  3. sudo su - oradev
  4. password
  5. echo $ORACLE_SID
  6. sqlplus / as sysdba
  7. create user identified by
  8. default tablspace The above steps need to get automate using a bat file which consist of plink/putty.

enter image description here

-Sayantan

Idan
  • 5,405
  • 7
  • 35
  • 52

1 Answers1

0

You can make a password and username txt file and maybe use the IF NOT EXIST Command to check if that user and pass file exists and set some commands up to create that file

Hope this is what you meant :)

  • if you have seen the pic in that i am able to get into the sudo but i need to enter the password. is there a way that the password be stored in a variable and pass when the prompt ask me the password. Basically, all that I am trying to do is 1) login to a server 2) type sudo su - db_instance 3) enter sudo password. I am able to automate step 1 and 2 and got stuck at 3 while passing the password using a batch file – SAYANTAN Chakraborty Nov 15 '16 at 14:51
  • @SAYANTANChakraborty Im gonna guess youre talking about using ftp so you may want to ask about that, im not an expert on ftp sadly so I cant help when it comes to servers –  Nov 15 '16 at 19:37
  • OK #yoshirou i can understand .. and thanks for your suggestion. – SAYANTAN Chakraborty Nov 16 '16 at 09:31