popen and cin

S

sam

Hi,

I try to use popen execute scp, when the user finish password, it will
return to the cin input prompt, but the problem is popen does not wait
for user finish typing up the password before displaying the cin input
prompt. As a result, the scp password input prompt does not receive any
input from user.

Here is few lines from the code:

popen("/usr/bin/scp /tmp/test [email protected]:~/", "w");
string commandline;
cout << endl << "User Prompt>>";
getline(cin, commandline, '\n');

Do I need to change popen to something else? or need to write my own
popen function to deal with the process waiting?

Thanks
Sam
 
A

Artie Gold

sam said:
Hi,

I try to use popen execute scp, when the user finish password, it will

popen() is not a standard C++ function, so you're off topic here...
return to the cin input prompt, but the problem is popen does not wait
for user finish typing up the password before displaying the cin input
prompt. As a result, the scp password input prompt does not receive any
input from user.

Here is few lines from the code:

popen("/usr/bin/scp /tmp/test [email protected]:~/", "w");

....and this line is nonsensical in any case (as you're throwing away the
result of the call -- which is all it's good for)...
string commandline;
cout << endl << "User Prompt>>";
getline(cin, commandline, '\n');

Do I need to change popen to something else? or need to write my own
popen function to deal with the process waiting?

Thanks
Sam

HTH,
--ag
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top