Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to automate the following command that runs on win xp (from CMD window )

     D:\Documents and Settings\muser>  erase_disk.exe 

after 10 minutes I get the question:
are you sure to erase disk(y/n)

Is it possible by using dos xp commands to send “y” character to command line? so I will not need to wait and type “y”

  • I have tried the following but its not works

           echo y| erase_disk.exe 
    

other different example

     D:\Documents and Settings\muser>  scan_virus_on_my_email.exe

after 1 hour I get:

                                       proccess ended to you want to exit (y/n)
share|improve this question

migrated from programmers.stackexchange.com Jul 12 '13 at 15:02

This question came from our site for professional programmers interested in conceptual questions about software development.

1  
The question seems valid, but thought I might suggest; lots of Linux programs I know of have an option to disable confirmations so they can be automated. I don't know if yours does. (entering "erase_disk.exe /h" might give you more information) –  Katana314 Jul 12 '13 at 13:24
    
yes but this is only example , what I want is to know if we can to auto CLI command in one line , I try many options to lunch the "y" argument in to the command line so it will be automate the proccess , but as you see I not succeed –  maihabunash Jul 12 '13 at 13:31
2  
You might want to check out the unix yes command (possibly getting the source and compiling it for dos). –  MichaelT Jul 12 '13 at 14:06
    
I am not sure if we can to it ( yes is linux/unix command ) - how to compile it to WIN ENV? –  maihabunash Jul 12 '13 at 14:11
    
@maihabunash you get a complier and compile the code. One version of it on google code. It should be trivial to write a similar program in a scripting language present on the machine if you don't have a compiler. –  MichaelT Jul 12 '13 at 14:16

1 Answer 1

It's been a really long time since I've done this, but in the past to automate some things we had a Y in a text file, like y.txt, and then in our batch files had statements like:

erase_disk < y.txt
share|improve this answer
    
That do work on Unix/Linux, but remember to insert an <kbd>ENTER</kbd> at the end of the line –  user61852 Jul 12 '13 at 13:58
    
how ? , if I put the "y" in y.txt how to edit the enter in the y.txt file? –  maihabunash Jul 12 '13 at 14:01
    
@maihabunash just hit enter after the "y". I used that technique once but I just needed the ENTER, so I created a file with just a new line character. –  user61852 Jul 12 '13 at 14:03
    
yes - I did it but still I get the question - are you sure to erase disk(y/n) –  maihabunash Jul 12 '13 at 14:05
    
I dont sure but maybe need to create soome .bat file that send the "y" string to CLI - am I right? –  maihabunash Jul 12 '13 at 14:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.