use Expect; $Expect::Exp_Internal = 1; # for debugging my $cmd = Expect->spawn('/usr/bin/sshfs', 'root@moto:/mnt/sdcard/eBooks', 'mnt') or die $!; $cmd->expect(undef, 'root@moto\'s password: '); $cmd->send("XXXX\n"); #### Spawned '/usr/bin/sshfs root@moto:/mnt/sdcard/eBooks mnt' spawn id(3) Pid: 11716 Tty: /dev/pts/2 at /home/mh/perl5/perlbrew/perls/perl-5.18.1/lib/site_perl/5.18.1/Expect.pm line 181. Expect::spawn('Expect', '/usr/bin/sshfs', 'root@moto:/mnt/sdcard/eBooks', 'mnt') called at ./mnt.pl line 11 Starting EXPECT pattern matching... at /home/mh/perl5/perlbrew/perls/perl-5.18.1/lib/site_perl/5.18.1/Expect.pm line 561. Expect::expect('Expect=GLOB(0xfe0ab8)', undef, 'root@moto\'s password: ') called at ./mnt.pl line 12 spawn id(3): list of patterns: #1: -ex `root@moto\'s password: ' spawn id(3): Does `' match: pattern #1: -ex `root@moto\'s password: '? No. Waiting for new data (unlimited seconds)... root@moto's password: spawn id(3): Does `root@moto\'s password: ' match: pattern #1: -ex `root@moto\'s password: '? YES!! Before match string: `' Match string: `root@moto\'s password: ' After match string: `' Matchlist: () Returning from expect successfully. Sending 'XXXX\n' to spawn id(3) at /home/mh/perl5/perlbrew/perls/perl-5.18.1/lib/site_perl/5.18.1/Expect.pm line 1264. Expect::print('Expect=GLOB(0xfe0ab8)', 'XXXX\x{a}') called at ./mnt.pl line 13