node-cmd icon indicating copy to clipboard operation
node-cmd copied to clipboard

answering to a CMD y/n prompt

Open alaa-fouzai opened this issue 3 years ago • 2 comments

hello

i was using this library and its quite good

but unfortunately the command im using prompts me to accept or deny via y/n

image

i was wondering if the library allows me to answer to this prompt if it is possible can you provide me with a sample code ,all i found is retrieving the process id is there a way to reconnect and answer y to the process ?

i already tried this const syncDir=cmd.run('cd ../tools/ && ffmpeg -i input.mkv -t 10 test3.mkv' ,function(err, data, stderr){ console.log('running'); console.log('data ',data); console.log('stderr ',stderr); console.log('err ',err); if ( stderr.includes('already exists. Overwrite ? [y/N]')) { data.stdin.write("y"); console.log('accepting '); } });

but i couldn't make it work if its not possible i can work around it but i wanted to check with you guys beforehand

alaa-fouzai avatar Feb 14 '22 22:02 alaa-fouzai

You should just be able to send the commands over the line. the pipe is open. Sorry for the delay in response. I'll do my best to help out if you are still having troubles.

RIAEvangelist avatar Mar 07 '22 06:03 RIAEvangelist

Also, I think the Python Shell example might be helpful

RIAEvangelist avatar Mar 07 '22 08:03 RIAEvangelist