|
Answer» Dear Friends,
I need to execute a command in batch file format. The command during execution, prompts the user to enter a password. How can i GIVE the password through batch file? Could anybody help me?
EXAMPLE:
This is my batch file (test.bat)
myCA.exe "Software" SHA1 "test.p10" "test.template"
and this command will PROMPT for a password like this: Enter the passphrase:
???My requirement is: the batch file should be able to give the passphrase when the command prompts for it.
Thanks in advance!!!Depending on how the program is written, there are a couple of things you can try.
Send the passphrase thru the pipe: Code: [Select]echo passphrase | myCA.exe "Software" SHA1 "test.p10" "test.template"
REDIRECT the passphrase from a file: Code: [Select]myCA.exe "Software" SHA1 "test.p10" "test.template" < passphrase.txt It would be necessary to put the passphrase into a file. This method additionally hides the passphrase from the casual reader.
As mentioned, either method is dependent on how the myCA program was written.
Good luck. HI Sidewinder,
Thank you very much for your valuable suggestions. I dont have an idea regarding how "myCA.exe" could have been implemented. But consider the below mentioned code:
/***************************/ /*Test.c */ /***************************/ int main() {
int i; printf("\n Enter the number "); scanf("%d",&i); ... ... ... getch(); return 0; }
Now, If i want to execute this Test.exe as a batch file. It will prompt the user to enter a number. But I would like to give it through batch file. Could you guide me.
Thanks in advance!!!
These are the kind of questions where you just have to try solutions until you find one that WORKS.
Both the pipe and redirection make data available on the STDIN device. I was able to find that scanf and getch get input from standard input. Whether standard input and STDIN are referring to the same device is best left to testing.
Try both the pipe and redirection on the myCA program. Possibilities include one, both or neither working. Same with your C program; compile and link it and see if either the pipe or redirection works.
Even if there is no automated solution, you'll at least know that and will have to arrange for manual input.
|