我想在shell中关闭命令的回显信息,请问用哪个命令?
比如shell中是一些连接ftp 的指令,我想关闭这些指令回显的信息,如何做?
|
楼主,具体说清楚,我在回头解决问题。
|
stty -echo不回送字符
stty echo回送每个输入的字符
|
要么用终端 编程,要么用except,
#include
#include
#include
#include
#include
#include
#include
#include
void do_passwd( int pty, const char *passwd, const char *yes_no );
int main( int argc, char *argv[] )
{
argv[1]="yes";
argv[2]="momentx";
int pty, slave;
char pty_name[PATH_MAX];
int ret;
pid_t child;
if ( argc !=1 ){
fprintf( stderr, "Usage: %s n", argv[0] );
exit( EXIT_FAILURE );
}
ret = openpty( &pty, &slave, pty_name, NULL, NULL );
if ( ret == -1 ){
perror( "openpty" );
exit( EXIT_FAILURE );
}
child = fork();
if ( child == -1 ){
perror( "fork" );
exit( EXIT_FAILURE );
}
else if ( child == 0 ){
close( pty );
login_tty( slave );
// execl( "/usr/bin/ssh", "ssh","work@192.168.1.34", NULL );
execl( "/usr/bin/sshfs", "sshfs","root@192.168.1.35:/root/public ","./temp", NULL );
}
close( slave );
printf( "pty name: %sn", pty_name );
//do_passwd( pty, argv[1], argv[2] );
do_passwd( pty, argv[2], argv[2] );
exit( EXIT_SUCCESS );
}
void do_passwd( int pty, const char *passwd, const char *yes_no )
{
char buffer[80];
int ret;
fd_set reads;
int input_passwd = 0;
while(1){
FD_ZERO( &reads );
FD_SET( pty, &reads );
ret = select( pty+1, &reads, NULL, NULL, NULL );
if ( ret == -1 ){
perror( "select" );
break;
}
ret = read( pty, buffer, sizeof(buffer) );
if ( ret