Log in to users.cs.umb.edu
- Log in to a Windows machine
Enter your Unix username as the account name. Then enter your password.- Run the ssh client
Use the values in the table below to connect to users.
ssh configuration parameter value protocol ssh ssh version 2 ssh port 22 host users.cs.umb.edu user name your unix username Authentication method password - Enter your password
A dialog box will appear on the screen into which you must type the password for your Unix account.- Make sure you are in your home directory
cd- Go to your it441 directory
cd it441- Go to your ex directory
cd ex- Create an ex07 directory
mkdir ex07- Go to your ex07 directory
cd ex07- Execute the script command
script- Use your perlsession alias to start the re.pl script.
perlsession(NOTE: If the perlsession alias is not recognized, or if re.pl cannot run, then double-check your Perl configuration, as well as your login shell vs. subshell environments!)Writing to a another terminal, instead of a file
Open a second ssh session for yourself on users.cs.umb.edu.
(No need to use script or perlsession here!)Execute the tty command to get your terminal's path, which will be of this form: /dev/pts/23 Below, replace /dev/pts/23 with the path that the tty command gave youperl> open ( OUT4 , '>' , '/dev/pts/23' ) or die $!; perl> print OUT4 "first\n"; perl> print OUT4 "second\n"; perl> print OUT4 "third\n"; perl> print OUT4 "fourth\n"; perl> close (OUT4);
(Look at your other terminal? What happened, and why?)Piping into your script code -- from another process
Here, we will use a Linux command to choose all the usernames that contain "ll" and read them into our script code. This is to avoid the longer output we would get from printing every username!
perl> open ( IN5 , '-|' , 'ls /home | grep ll' ) or die $!; perl> while (<IN5>) { chomp ; print $_ ; print ", " ; } print "\n" ; perl> close (IN5);Piping from your script code -- into another process
perl> open ( OUT6 , '|-' , 'sort -r' ) or die $!; perl> while (<STDIN>) { $_ = uc $_ ; print OUT6 $_ ; }At this point, it will appear to stall, but what's actually happening is this: It is waiting for you to enter lines of text. Just type something and press Enter. Then, do this again, at least four more times. When you are done entering lines of text, press Ctrl+D. This signals the end of input so that the while loop stops executing.perl> close (OUT6);(What happens after you enter the line close (OUT6); ?)Piping in both directions
perl> open ( IN7 , '-|' , 'ls /home | grep ll' ) or die $!; perl> open ( OUT7 , '|-' , 'sort -r' ) or die $!; perl> while (<IN7>) { $_ = uc $_ ; print OUT7 ; } perl> close (IN7); perl> close (OUT7);End the Perl Session
perl> exitEnd the script session
Use the exit command. You should then have a file called typescript in your current working directory.