From: Kevin S. <ke...@ne...> - 2002-08-30 07:22:09
|
Has anyone tried to control screen with expect? I would like to get a perl prog to start a screen Then run an app and disconnect. Then at some time later (possibly weeks) connect to the screen and issue commands to the prog running in the screen, with the possibility of stoping (ctrl-c) and restarting the app in the same screen process screen -C "command" does not work as screen exits when the command exits this is the basic outline and fails miserably #!/usr/bin/perl -w use strict; use Expect; my $screen="/usr/bin/screen"; my @args=("-S","bob"); my $app=Expect->spawn($screen,@args); #unless ($app->expect(10,-re,"\$")){ # print "did not get prompt\n"; # exit; #} print "got prompt\n"; sleep 1; $app->print("echo hello\r"); #unless ($app->expect(10,"$ARGV[1]")){ # print "did not get text back\n"; # exit; #} print "closing\n"; $app->print("\001\003"); unless ($app->expect(10,"screen is terminating")){ print "did not detach\n"; } print "done\n"; |