cs2044_Lecture6

cs2044_Lecture6 - CS2044 Advanced Unix Tools Spring 2010...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS2044 - Advanced Unix Tools Spring 2010 Lecture 6 David Slater dms236 at cornell.edu March 5, 2010 David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools Organization Homework 1 due this afternoon! Turn In Code That Works! David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools Some Review What does this do? gawk ’BEGIN { max = 0 } { if (length($0) > max); max = length($0) } END { print max } ’ infile David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools Some Review What does this do? gawk ’BEGIN { max = 0 } { if (length($0) > max); max = length($0) } END { print max } ’ infile Prints the length of the longest line gawk ’END { print NR } ’ infile David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools Some Review What does this do? gawk ’BEGIN { max = 0 } { if (length($0) > max); max = length($0) } END { print max } ’ infile Prints the length of the longest line gawk ’END { print NR } ’ infile Prints how many lines are in the file #! /bin/bash gawk ’$1 = "’$1’" { count++ ; print $2 } END { print count } ’ infile David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools Some Review What does this do? gawk ’BEGIN { max = 0 } { if (length($0) > max); max = length($0) } END { print max } ’ infile Prints the length of the longest line gawk ’END { print NR } ’ infile Prints how many lines are in the file #! /bin/bash gawk ’$1 = "’$1’" { count++ ; print $2 } END { print count } ’ infile Prints the second field whenever the first matches the first argument and then prints the total number of matched lines. David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools Random Bash Encounter Of The Day If you are like me you ssh into machines alot. You also move files using sftp/scp. Wouldn’t it be great to be able to Not have to type your password everytime? Use ssh, scp or sftp inside a script? Well now you can! OpenSSH Public Keys Alows clients to access servers with passphrase-free logins. David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools Setting up OpenSSH Step 1: Make sure you are using OpenSSH ssh -V Step 2: Generate your key ssh-keygen -q -f ~/.ssh/id_rsa -t rsa Note: Do not use your account or an empty password This creates two files, id_rsa and id_rsa.pub David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools Setting up OpenSSH Copy the id_rsa.pub file to the server scp ~/.ssh/id_rsa.pub example.server.org Append the contents of the file to the ~/.ssh/authorized_keys file on the server cat ~/id_rsa.pub >> ~/.ssh/authorized_keys rm id_rsa.pub Check to make sure it worked: ssh -o PreferredAuthentications=publickey server.exampleorg On my machine, ssh-agent starts when gnome starts. So I just need to add my key by typing ssh-add And I’m all done!...
View Full Document

This document was uploaded on 03/15/2010.

Page1 / 40

cs2044_Lecture6 - CS2044 Advanced Unix Tools Spring 2010...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online