User Tools

Site Tools


haas:fall2020:common:helpances:startingpctx

This is an old revision of the document!


An insightful conversation (featuring “H” and “K”, two pilgrims on their journey towards enlightenment) on the way to pctX-starting clarity…

H: I’m going to be honest I’m a bit confused with pct1

wedge: Oh? Where are you- just trying to start?

wedge: Or hit a wall?

wedge: What is long division?

wedge: What are numbers?

K: I cant even get into the directory

wedge: @K what do you mean: you can't get into the directory? It is on lab46

H: I just don’t know how to access the puzzle

wedge: ah, ok! Two birds with one stone

K: It says the pctX directory

wedge: but it also says to substitute the X with whatever pct# project you are working on

K: aha!

wedge: step the one: log onto lab46 via ssh/mosh

H: check

wedge: it then has you navigating into the UNIX public directory.

wedge: that information (the public directory) has been provided to you on the info table near the top of the syllabus. Can you locate it? (the public directory path, near the top of the syllabus/course homepage)

K: I see it now

H: Me too, took me a sec… Ooooh

wedge: that is a directory path

wedge: meaning (if you've been reading the Mages book), you'll have to change directory to there

wedge: any issues with that?

K: So we would type cd then the public directory?

wedge: yes, exactly

H: You would do cd and only a / for var

wedge: well: cd PATH

wedge: so you take that whole public directory path you found on the syllabus

lab46:~$ cd /the/public/directory/path
lab46:/the/public/directory/path$ 

wedge: … and you should see your prompt change accordingly if you typed it in correctly

wedge: yes?

H: It hasn’t changed my prompt, mine is just showing lab46: /var/public/fall2020/unix$

wedge: It DID change your prompt

wedge: Notice how it put the path you just cd'ed to INTO your prompt @KalebJ12 try that exact same command again it should work now KalebJ12Yesterday at 4:18 PM It did lol HannahH02Yesterday at 4:19 PM Oh oh oh, blonde moment when you sent that screenshot I thought it was supposed to say directory lol wedgeYesterday at 4:19 PM capital “UNIX” didn't exist (just the lowercase “unix”), so I fixed that KalebJ12Yesterday at 4:19 PM Ahh wedgeYesterday at 4:19 PM your prompt always attempts to tell you 2 important pieces of information: 1. the system you are on (lab46 vs. your pi) 2. WHERE you are if you are in your home directory, instead of seeing “lab46:/home/username$” it uses the '~' as a shortcut to represent home directory if you were to “cd” into your “public_html” directory, it would show: lab46:~/public_html$ because that is INSIDE your home directory where as the public directory: is external to your home so, it shows the ENTIRE path, what is known as an “absolute path” now: if you are there, IN the UNIX public directory, let us take a look around. How do we see what is there, in the public directory? KalebJ12Yesterday at 4:23 PM Hg status? wedgeYesterday at 4:23 PM nope.. that's for your repository. We're nowhere near it we are in a directory. Directories contain files. How do we see the files contained within a directory? (again, Mages book stuff) KalebJ12Yesterday at 4:24 PM Find? HannahH02Yesterday at 4:24 PM Less and more command? wedgeYesterday at 4:24 PM nope (well, yes, but by no means the most convenient nor direct way) less/more are used commonly WITH other commands, or to view inside text files we have a directory here, which is NOT a text file (although, it may contain text files) other names for the action may include “listing” the files KalebJ12Yesterday at 4:26 PM Ls? HannahH02Yesterday at 4:26 PM Ohh lad Auto correct lol wedgeYesterday at 4:26 PM yes, only all lowercase KalebJ12Yesterday at 4:26 PM ls -a? wedgeYesterday at 4:26 PM what happens when you run “ls”? KalebJ12Yesterday at 4:27 PM It shows both files wedgeYesterday at 4:27 PM no need for '-a' in this setting, JUST “ls” HannahH02Yesterday at 4:27 PM I see pct1 and pct2 KalebJ12Yesterday at 4:27 PM Pct1 and Pct2 wedgeYesterday at 4:27 PM yes. Blue, correct? that means they are directories HannahH02Yesterday at 4:27 PM Yes wedgeYesterday at 4:27 PM (again, case matters: pct1, pct2) hey, directories… you know something about dealing with directories… how would you go into the pct1 directory? HannahH02Yesterday at 4:28 PM ace CD Autocorrect again KalebJ12Yesterday at 4:28 PM cd /pct1 wedgeYesterday at 4:28 PM no / the / means “from the base of the system” KalebJ12Yesterday at 4:28 PM Okay wedgeYesterday at 4:28 PM var is at the base of the system, so we prefix / to var when we are doing short hops like this (known as a relative path), we just specify the name your prompt should change (pct1 should append to the end) KalebJ12Yesterday at 4:29 PM I'm already learning a lot lol HannahH02Yesterday at 4:29 PM What was the path called with /, I know it starts with an a wedgeYesterday at 4:29 PM :slight_smile: all it took was asking a question absolute HannahH02Yesterday at 4:29 PM Ah yes KalebJ12Yesterday at 4:30 PM Woah so if I ls I see everyones account and the files wedgeYesterday at 4:30 PM absolute paths start with /, relative paths do not yep any files of particular interest? KalebJ12Yesterday at 4:30 PM Manifest HannahH02Yesterday at 4:30 PM I’m only half way through the mage book and there is so much info in it lol wedgeYesterday at 4:31 PM :slight_smile: hey, you're already well on your way considering the semester hasn't even started yet EVERYONE will need to go through what you are experiencing now… making those essential connections you stand to have a much easier time, because we have so much time KalebJ12Yesterday at 4:32 PM So say I wanted to be in the same place i am rn on my pi is that possible? wedgeYesterday at 4:32 PM that directory would have to exist on your pi (it does not) HannahH02Yesterday at 4:32 PM Now I see puzzle, this is making a lot more sense wedgeYesterday at 4:32 PM (but don't worry, when we're done you should have your puzzle on your pi) KalebJ12Yesterday at 4:33 PM I only see manifest HannahH02Yesterday at 4:33 PM You’ll need to go into your name wedgeYesterday at 4:33 PM sometimes it just takes a question to be asked :slight_smile: yep KalebJ12Yesterday at 4:33 PM Got it wedgeYesterday at 4:33 PM also: have you all set up your repository on lab46 (and your pi)? KalebJ12Yesterday at 4:33 PM Yes I did that today I submitted ntr0 and I was going to help Hannah on her ntr0 HannahH02Yesterday at 4:34 PM I haven’t done it on my pi yet but I just put it together so I will later today wedgeYesterday at 4:34 PM I only ask so as to better calibrate my answer… okay, so yes to lab46 at least on both? KalebJ12Yesterday at 4:34 PM Yes HannahH02Yesterday at 4:34 PM Yes wedgeYesterday at 4:34 PM good. ok so you wander into your respective “username” directory. What is there? KalebJ12Yesterday at 4:35 PM On my pi? wedgeYesterday at 4:35 PM on lab46 where we are now KalebJ12Yesterday at 4:35 PM Puzzle HannahH02Yesterday at 4:35 PM Under ls is puzzle wedgeYesterday at 4:35 PM yes, you should see a single (gray/white) file called 'puzzle' files that are coloured gray/white are “regular” files… which includes things like text files how could we view this file, assuming it was a text file? (there are MANY ways) HannahH02Yesterday at 4:37 PM Do we use the more and less commands with this one? wedgeYesterday at 4:37 PM and you both have mentioned possibilities yes: less or more can do the job so can nano but I'll give you one simpler the command known as: cat KalebJ12Yesterday at 4:37 PM I like nano wedgeYesterday at 4:37 PM cat filename can is like a straight up file viewer displays the contents to your screen and returns to the prompt (unlike nano or more/less, cat is NON-INTERACTIVE, meaning it just does its thing, without any further interaction from the user) if you cat your 'puzzle' file , you should see the puzzle. Yes? HannahH02Yesterday at 4:39 PM Yes, so should we work on paper then just add it on nano? wedgeYesterday at 4:40 PM yes KalebJ12Yesterday at 4:40 PM Mine seems like its solved wedgeYesterday at 4:40 PM BUT: I'll do one better I'll now show you how to copy that puzzle file INTO your repository, into a pct1 directory of your own. @KalebJ12 it isn't solved, you need to figure out the numeric identity of the letters KalebJ12Yesterday at 4:41 PM OHHHH okay wedgeYesterday at 4:41 PM ok: getting our puzzle into our repository KalebJ12Yesterday at 4:41 PM So do we make the directory on the pi with mkdir wedgeYesterday at 4:42 PM it might be a good idea to set up a structure, so all are class data is organized @KalebJ12 nope, we're going to make mercurial do it KalebJ12Yesterday at 4:42 PM Okay wedgeYesterday at 4:42 PM but we ARE going to run mkdir on lab46: mkdir -p ~/src/unix/pct1

can you then tell me, WHERE is that? KalebJ12Yesterday at 4:43 PM We should go back to lab46: ~$ first right? Or does it not matter wedgeYesterday at 4:43 PM nope doesn't matter but ONLY because I am giving it an absolute path I mentioned ~ before what is it? HannahH02Yesterday at 4:44 PM Nothing happened for me wedgeYesterday at 4:44 PM correct: mkdir did what was requested of it KalebJ12Yesterday at 4:44 PM It made it but we arent in it so now we go into it wedgeYesterday at 4:44 PM if you just get your prompt back, you were successful UNIX is “user friendly” like that… it doesn't go and say “SUCCESS! YOU DID THE THING. ARE YOU SURE?” it assumes you know what you are doing KalebJ12Yesterday at 4:45 PM We have to copy the puzzle file to the new directory we just made wedgeYesterday at 4:45 PM we just made a new directory, INSIDE our home directory (~), under src (created when you set up your repo on lab46) actually created a “unix” subdirectory, and inside that, “pct1” we can now copy our puzzle file here, INTO that ~/src/unix/pct1 directory any ideas how we might do that? KalebJ12Yesterday at 4:46 PM cp file name HannahH02Yesterday at 4:46 PM Cp? Ah wedgeYesterday at 4:46 PM cp source destination here we are in the public directory… pct1… puzzle is here so 'puzzle' will be our source KalebJ12Yesterday at 4:47 PM cp pct1 wedgeYesterday at 4:47 PM and the destination? KalebJ12Yesterday at 4:47 PM Dang cp pct1 /src/unix/pct1 wedgeYesterday at 4:48 PM careful- src is not at the base of the filesystem… it is in our home directory (~) HannahH02Yesterday at 4:48 PM How do we get the puzzle in there though, do we use the name puzzle? wedgeYesterday at 4:48 PM cp puzzle ~/src/unix/pct1 HannahH02Yesterday at 4:48 PM Gotcha KalebJ12Yesterday at 4:48 PM I was so close dang wedgeYesterday at 4:48 PM yes: puzzle is the source ~/src/unix/pct1 is the destination again: you should get your prompt back if you did it correctly yes? KalebJ12Yesterday at 4:49 PM Yes wedgeYesterday at 4:49 PM now: CHANGE DIRECTORY to that destination KalebJ12Yesterday at 4:49 PM Done wedgeYesterday at 4:50 PM prompt should change to: lab46:~/src/unix/pct1$ yes? HannahH02Yesterday at 4:50 PM Got it wedgeYesterday at 4:50 PM ok. an 'ls' should confirm our file is there HannahH02Yesterday at 4:50 PM Yes KalebJ12Yesterday at 4:50 PM Yup wedgeYesterday at 4:50 PM a 'cat' should confirm that the contents are still there KalebJ12Yesterday at 4:50 PM Yes HannahH02Yesterday at 4:50 PM Yes wedgeYesterday at 4:50 PM but now: anything under ~/src/ is trackable by mercurial, in our repository so, go and ADD puzzle to your repository (that hg thing) hg add puzzle it may say “added puzzle” or some such thing yes? KalebJ12Yesterday at 4:52 PM Mine didnt say anything but I did it again and said that its already there wedgeYesterday at 4:52 PM ok, good KalebJ12Yesterday at 4:52 PM So it worked wedgeYesterday at 4:52 PM actually: hg status it should also show 'puzzle', with a green capital A to the left of it KalebJ12Yesterday at 4:53 PM A unix/pct/puzzle wedgeYesterday at 4:53 PM hg status shows us the state of the current snapshot yes HannahH02Yesterday at 4:53 PM Sweet got it wedgeYesterday at 4:53 PM okay, now COMMIT it: hg commit -m “adding my pct1 puzzle” HannahH02Yesterday at 4:54 PM What does commiting it do? wedgeYesterday at 4:54 PM takes a snapshot KalebJ12Yesterday at 4:54 PM Like a log? Of what's happening wedgeYesterday at 4:54 PM the current state of all the files listed in 'hg status' like it saves the current instance of the file but yes, in log-like fashion KalebJ12Yesterday at 4:55 PM So should we hg push? wedgeYesterday at 4:55 PM yes push sends the snapshot to the server which for the purposes of getting it on the pi, definitely something we want so do that. at this point, @HannahH02 , since you haven't set it up on your pi yet, will be something to check out later but basically: once you have added, committed, and pushed it HannahH02Yesterday at 4:56 PM In the future do we work more on the pi or lab 46? wedgeYesterday at 4:57 PM you can switch over to your pi, go into your ~/src directory on your pi (the intent is, yes, that you do the bulk of the work on the pi) mainly getting files from and putting finished files to submit back on lab46 @KalebJ12 in your ~/src on your pi? KalebJ12Yesterday at 4:57 PM Yed Yes wedgeYesterday at 4:57 PM hg pull then: hg update then, do an 'ls' KalebJ12Yesterday at 4:58 PM Unix shows up wedgeYesterday at 4:58 PM go in there run 'ls' KalebJ12Yesterday at 4:58 PM ntr0 and pct1 wedgeYesterday at 4:59 PM go into pct1 run 'ls' KalebJ12Yesterday at 4:59 PM Hey puzzle is there wedgeYesterday at 4:59 PM :slight_smile: there you go now, to get things from your pi back to lab46– add/commit/push on the pi then on lab46: pull, update back and forth, whichever way you need at the moment KalebJ12Yesterday at 4:59 PM Yeah I had to do that with ntr0 wedgeYesterday at 5:02 PM so there you go: I hope that helped clarify things somewhat :slight_smile: HannahH02Yesterday at 5:02 PM Thank you for all your help! wedgeYesterday at 5:02 PM no problem! Thank you for asking questions KalebJ12Yesterday at 5:03 PM So 9 = K is the highest number? wedgeYesterday at 5:04 PM maybe um… you don't have a K KalebJ12Yesterday at 5:05 PM I was looking at the chart on the lab46 website wedgeYesterday at 5:06 PM oh, the puzzle I walk through on the project page? KalebJ12Yesterday at 5:06 PM Yes Do we ever go above the letter k? wedgeYesterday at 5:06 PM yes, in that puzzle, K is 9 Yes: when we work on a puzzle in a base higher than 10 KalebJ12Yesterday at 5:07 PM Oh no lol wedgeYesterday at 5:07 PM for the foreseeable future, we'll be working in base 10 but we will dabble in other bases… 8, 9, 11 in 8, there is no 9 (or 8!)… we go from 0-7 but, nothing to fret about at present… just focus on base 10 :slight_smile: KalebJ12Yesterday at 5:08 PM Okay wedgeYesterday at 5:11 PM by the way: the point of pctX is to get you to strengthen your abilities to describe a process (and think critically)… since we'll eventually be writing shell scripts, it helps if you've got some experience tending to details from start to finish of a particular task because if you cannot specifically describe from start to finish a process you are personally doing by hand, you're going to have a heck of a time instructing the computer to do something. plus, they're super fun, and you'll eventually want to do them all the time! KalebJ12Yesterday at 5:16 PM So with the puzzle if we submit the wrong answers do we get points off lol wedgeYesterday at 5:16 PM yes KalebJ12Yesterday at 7:46 PM On the pct1 our answer do we submit it as numbers or letters? wedgeYesterday at 8:08 PM You submit the letters in order from least to greatest There is an example on the projects page KalebJ12Yesterday at 8:10 PM No for the verify part where it shows the example of there being a remainder wedgeYesterday at 8:11 PM Oh, you don’t have the remainder. So you do a different verification (there is also an example on the project page) wedgeYesterday at 8:22 PM Basically switching out to numbers, solving, then switching back to letters to see if they match. The example is probably more helpful in showing what I mean

haas/fall2020/common/helpances/startingpctx.1597321860.txt.gz · Last modified: 2020/08/13 12:31 by wedge