School of Physics, Mathematics, and Computing 
Not logged in (login)
help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.

Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!" followup message.

How do I ask a good question?
 

Final examination information
Options:
RSS cloud
Jump to:

lab 1

12 of 951 articles shown, currently no other people reading this forum.
photo
From: ANONYMOUS
Date: Wed 4th Aug 2021, 8:55pm
Actions: 
Login-to-reply

Hi Chris,

In lab 1, I have managed to get ubuntu working given the instructions on the unit 
page, but upon attempting lab 1, I didn't really know how to access the rotate.c file 
in the terminal. I tried copy and pasting the C code into a text editor and calling 
the file 'rotate.c' but it is just telling me there is no such file or directory 
restraining me to not yet start the lab. Is there something I am missing? I feel like 
I am very close to getting it. any help would be greatly appreciated.

Thanks.

lab 1

photo
From: Christopher M.
Date: Thu 5th Aug 2021, 5:45am
Actions: 
Login-to-reply

ANONYMOUS wrote:
 
> In lab 1, I have managed to get ubuntu working given the instructions on the unit 
> page, but upon attempting lab 1, I didn't really know how to access the rotate.c file 
> in the terminal. I tried copy and pasting the C code into a text editor and calling 
> the file 'rotate.c' but it is just telling me there is no such file or directory 
> restraining me to not yet start the lab. Is there something I am missing? I feel like 
> I am very close to getting it. any help would be greatly appreciated.

Hi,

This a really a more general issue about how to access your Windows or macOS files while working 
inside docker+Linux.   Until familiarity grows, you'll probably find the following way easiest, as 
it:

  - gives you the ability to read and write your local files while in docker,
  - allows you to use your standard browser to download files (such as rotate.c)
  - (assuming that you're performing backups) files created/changed in docker will be backed up.

I've tested this on macOS, but not Windows (anyone else able to test this??)

Using the Docker Desktop (GUI) we first need to indicate that docker is permitted to access your 
local files (only required once):

   - DockerDesktop > Settings(button) > Resources > FileSharing > add(+) the name of your local directory
   - Apply & Restart

(on my Mac I added /Users/chris, which is my full home directory, but you could set just a
sub-directory for specific CITS2002 work).

Now, when you run docker, we need to add some command-line arguments:

  docker run --rm -it -v /Users/chris:/home/chris -w /home/chris --name ubuntu ubuntu:latest bash

(use your name, ANONYMOUS, not chris :-)

Now, when your Linux shell starts in docker, your present working directory will be /home/chris, 
rather than the root directory,  / , a much safer place to work, and you should able to see your 
existing files using  'ls'.

_____
Hope this helps.

lab 1

photo
From: ANONYMOUS  O.P.
Date: Thu 5th Aug 2021, 10:47am
Actions: 
Login-to-reply

Hi Chris,

This helps a lot, but still, a little unclear how to actually open that C file. Are we working in the terminal 
or in the Docker desktop? where are we supposed to actually change the C code according to the labsheet?

lab 1

photo
From: Christopher M.
Date: Thu 5th Aug 2021, 2:53pm
Actions: 
Login-to-reply

ANONYMOUS wrote:

> This helps a lot, but still, a little unclear how to actually open that C file. Are we working in the terminal 
> or in the Docker desktop? where are we supposed to actually change the C code according to the labsheet?

Hi,  I'm a bit confused as to where "you're up to" in the steps of:

  https://teaching.csse.uwa.edu.au/units/CITS2002/labsheets/install-linux.php

If you have a Ubuntu image downloaded and populated with necessary packages - providing the C compiler (essential) and 
your choice of tezt editor (vi/vim recommended if you don't already have a favourite - then you can run a new Linux 
terminal within DockerDesktop, or just through the existing terminal program on your system (my preference, as it saves 
on screen real-estate to use the same terminal program with multiple open tabs).

Then (assuming vi as your editor, and that you have the required C file in your present working directory), you run vi 
and pass the file's name on the command-line:

  prompt>  vi rotate.c

Then you're 'in' vi, and you can issue vi's commands navigate around the file or to edit it (switching backwards and 
forwards between command-mode and insert-mode:

  https://secure.csse.uwa.edu.au/run/help2002?hl=insert%20mode&a=26 )

When you've made all the edits you wish, you simply leave vi with two capital Z's - ZZ
and you'll be returned to the shell prompt, where you can compile the modified file:

  prompt>  cc -o rotate rotate.c

If there's no compilation errors (otherwise, back to editing....) you can run the successfully compiled program with:

  prompt>  ./rotate  yourstring

Does that help?

lab 1

photo
From: Amitava D.
Date: Thu 5th Aug 2021, 8:48pm
Actions: 
Login-to-reply

ANONYMOUS wrote:

> Hi Chris,
> 
> This helps a lot, but still, a little unclear how to actually open that C file. Are we working in the terminal 
> or in the Docker desktop? where are we supposed to actually change the C code according to the labsheet?

There is also a simpler editor in Ubuntu called 'gedit' 
Just 
$gedit <enter>
will open it, there is a menu at the top-left corner for loading file. There is a save button to save after editing. 

lab 1

photo
From: ANONYMOUS  O.P.
Date: Fri 6th Aug 2021, 10:55am
Actions: 
Login-to-reply

Thanks for the reply’s, I guess it is a little bit hard to explain over messages, is there any time today or early next week 
where I could potentially come and see either of you?

I would hate to fall behind!

Thanks

lab 1

photo
From: ANONYMOUS
Date: Fri 6th Aug 2021, 1:15pm
Actions: 
Login-to-reply

Hi, I tried this. but when I used the v rotate.c or vim rotate.c , it says cc: command not found. I have followed all the steps 
given, not sure what went wrong. 

lab 1

photo
From: Christopher M.
Date: Fri 6th Aug 2021, 2:46pm
Actions: 
Login-to-reply

ANONYMOUS wrote:

> Hi, I tried this. but when I used the v rotate.c or vim rotate.c , it says cc: command not found. I have followed all the steps 
> given, not sure what went wrong. 

You haven't indicated what system/environment you've using,
but this step from the webpage - https://teaching.csse.uwa.edu.au/units/CITS2002/labsheets/install-linux.php

  roo*@*b*n*u*5 apt-get install -y vim build-essential

will install both the vim editor and the (many) packages for the C compiler.
Have you followed those steps,  becuase they should install the 'cc' command for you ?

lab 1

photo
From: Christopher M.
Date: Fri 6th Aug 2021, 2:48pm
Actions: 
Login-to-reply

ANONYMOUS wrote:

> Thanks for the reply’s, I guess it is a little bit hard to explain over messages, is there any time today or early next week 
> where I could potentially come and see either of you?

As it appears that you're in Perth,  you've welcome to attend any of the weekly CITS2002 lab sessions (not just your allocated one), and ask 
questions of the lab facilitator, as well.

lab 1

photo
From: Malcolm M.
Date: Fri 6th Aug 2021, 11:20pm
Actions: 
Login-to-reply

"Christopher McDonald" <ch*i*.*c*o*a*[email protected]*a*e*u*a*> wrote:

> ANONYMOUS wrote:
>  
> > In lab 1, I have managed to get ubuntu working given the instructions on the unit 
> > page, but upon attempting lab 1, I didn't really know how to access the rotate.c file 
> > in the terminal. I tried copy and pasting the C code into a text editor and calling 
> > the file 'rotate.c' but it is just telling me there is no such file or directory 
> > restraining me to not yet start the lab. Is there something I am missing? I feel like 
> > I am very close to getting it. any help would be greatly appreciated.
> 
> Hi,
> 
> This a really a more general issue about how to access your Windows or macOS files while working 
> inside docker+Linux.   Until familiarity grows, you'll probably find the following way easiest, as 
> it:
> 
>   - gives you the ability to read and write your local files while in docker,
>   - allows you to use your standard browser to download files (such as rotate.c)
>   - (assuming that you're performing backups) files created/changed in docker will be backed up.
> 
> I've tested this on macOS, but not Windows (anyone else able to test this??)
> 
> Using the Docker Desktop (GUI) we first need to indicate that docker is permitted to access your 
> local files (only required once):
> 
>    - DockerDesktop > Settings(button) > Resources > FileSharing > add(+) the name of your local directory
>    - Apply & Restart
> 
> (on my Mac I added /Users/chris, which is my full home directory, but you could set just a
> sub-directory for specific CITS2002 work).
> 
> Now, when you run docker, we need to add some command-line arguments:
> 
>   docker run --rm -it -v /Users/chris:/home/chris -w /home/chris --name ubuntu ubuntu:latest bash
> 
> (use your name, ANONYMOUS, not chris :-)
> 
> Now, when your Linux shell starts in docker, your present working directory will be /home/chris, 
> rather than the root directory,  / , a much safer place to work, and you should able to see your 
> existing files using  'ls'.
> 
> _____
> Hope this helps.

My windows 10 docker (WSL2) doesn't have a "fileSharing" option in the dockersDesktop > Settings > resources 
dialog (see 1st screenshot). also, "wget https://teaching.csse.uwa.edu.au/units/CITS2002/labsheets/rotate.c" 
in the docker terminal  results in an error (2nd screenshot) 

Attempting the "Shift / Right click / Open Linux Terminal" trick and using "cp rotate.c ~/CITS2002/lab01" 
worked, but only inside the shell it opened (the docker shell couldn't see rotate.c) (2nd screenshot)

I'm not sure if this is related or not, but I also noticed that each time I type "exit" in the docker linux 
shell command interface (and return to the windows command prompt), when i return to the linux command via 
the "run -it --rm --name myubuntu myubuntu bash" command, everything disappears (e.g. the bash_profile file, 
the entire "CITS2002" directory, all the new user "whoops!" files, etc.). Why does this happen? Is there some 
way to use the docker linux command instance but not lose all my files every time we exit the docker linux 
command mode?  Barring that, is it possibly better to just use the "right click -> open linux shell here" 
option to gain access to linux command window that we should be using to start on the lab work and 
potentially the rest of the projects for the semester?

lab 1

photo
From: Malcolm M.
Date: Fri 6th Aug 2021, 11:22pm
Actions: 
Login-to-reply

Screenshot 2 as mentioned

lab 1

photo
From: Christopher M.
Date: Sat 7th Aug 2021, 6:35am
Actions: 
Login-to-reply

"Malcolm Muller" <23*1*9*[email protected]*u*e*t*u*a*e*u*a*> wrote:

> My windows 10 docker (WSL2) doesn't have a "fileSharing" option in the dockersDesktop > Settings > resources 
> dialog (see 1st screenshot). also, "wget https://teaching.csse.uwa.edu.au/units/CITS2002/labsheets/rotate.c" 
> in the docker terminal  results in an error (2nd screenshot)

That missing 'fileSharing' option in the Dashboard may only be required/exist on macOS,  perhaps needed to politely 
interface with macOS's   System Preferences > Sharing > File Sharing  dialogue.
There may be a functionally equivalent mechanism on Windows, or it may not be required at all. ??
  

> I'm not sure if this is related or not, but I also noticed that each time I type "exit" in the docker linux 
> shell command interface (and return to the windows command prompt), when i return to the linux command via 
> the "run -it --rm --name myubuntu myubuntu bash" command, everything disappears (e.g. the bash_profile file, 
> the entire "CITS2002" directory, all the new user "whoops!" files, etc.). Why does this happen? Is there some 
> way to use the docker linux command instance but not lose all my files every time we exit the docker linux 
> command mode?  Barring that, is it possibly better to just use the "right click -> open linux shell here" 
> option to gain access to linux command window that we should be using to start on the lab work and 
> potentially the rest of the projects for the semester?

Not strictly related but, agreed, you don't wish to lose your working environment each time you exit a container.
Keep your working files for labs and projects within your Windows file system (not within the docker container, which 
will throw them away on exit, unless a new image is created).

My reading of StackOverFlow indicates that this is the same from Windows and macOS, just needing to specify the correct 
path to your Windows files:

  https://stackoverflow.com/questions/45267457/access-file-of-windows-machine-from-docker-container
  https://secure.csse.uwa.edu.au/run/help2002?p=np&a=55
This Page


Program written by: [email protected]
Feedback welcome
Last modified:  4:54pm Oct 24 2021