Faculty of Engineering and Mathematical Sciences 
Not logged in (login)

help4407


This forum is provided to promote discussion amongst students enrolled in Open Source Tools and Scripting (CITS4407).
 
Options:
RSS cloud
Jump to:

Assignment 2, Q1

16 of 390 articles shown, currently no other people reading this forum.
photo
From: Mingbo Z.
Date: Mon 11th May 2020, 4:47pm
Actions: 
        Login-to-reply

 

Hi Chris,

For the first task, do we need to detect the change of project content? When we run the shellscript, we just need to update the version number. Or our shellscript only update the version number when the content was changed. Thank you! 

Assignment 2, Q1

photo
From: Christopher M.
Date: Mon 11th May 2020, 5:04pm
Actions: 
        Login-to-reply

 

"Mingbo Zhang" <22*9*0*[email protected]*u*e*t*u*a*e*u*a*> wrote:

> Hi Chris,
> 
> For the first task, do we need to detect the change of project content? When we run the shellscript, we just need to update the version number. Or our shellscript only update the version number when the content was changed. Thank you! 

Hello Mingbo,

Your solution doesn't need to detect any changes  (which you could do with 'diff' - but don't!)

We're imagining that the human programmer has decided it's time for the software's next version to be released,
and so they just type:

    make updateversion

which calls your shellscript, which either detects mismatched versions, or performs the change everywhere.

Assignment 2 - Q1

photo
From: Nathan S.
Date: Tue 12th May 2020, 12:03pm
Actions: 
        Login-to-reply

 

Hi Chris, I have read the other related topics for Q1 and they do not answer my 
question.

For Q1, what exactly do you want?  In the assignment spec you indicate a shell script 
which accepts one arg (the project name), however in one of the answers on the help 
forum you seem to indicate that you want something that runs with 'make updateversion'  
, in this case there are no args passed and it is using make.  So updateversion is a 
Makefile?  
-----------------------------------

My understanding was that you want a bash script that accepts one argument (the 
project name), so we run it like '>/updateversion some_project_name'.  It then looks 
in the folder in which the script is located for 'Makefile', which it opens and checks 
the header comment '# projectname, ...' to match with the project name arg passed to 
the script.  Once that is all done, it can then deconstruct the Makefile extracting 
all the .c and .h filenames and then going and finding each one and changing the 
header comment as well as noting any anomalies.  Finally, it then changes the header 
comment in 'Makefile' itself.  All this done with the bash script, nothing to do with 
make.  However, I'm not sure about that last comment => 'Finally, add a new target to 
the project's Makefile to update the version number in the C source files and in the 
Makefile.'  Hang-on, I thought my script was supposed to have already done that!?

Reagrds,

Nathan

Assignment 2 - Q1

photo
From: Christopher M.
Date: Tue 12th May 2020, 12:18pm
Actions: 
        Login-to-reply

 

Hi Nathan,

"Nathan Scott" <18*1*1*[email protected]*u*e*t*u*a*e*u*a*> wrote:

> Hi Chris, I have read the other related topics for Q1 and they do not answer my 
> question.
> 
> For Q1, what exactly do you want?  In the assignment spec you indicate a shell script 
> which accepts one arg (the project name), however in one of the answers on the help 
> forum you seem to indicate that you want something that runs with 'make updateversion'  
> , in this case there are no args passed and it is using make.  So updateversion is a 
> Makefile?

Running   make updateversion

requests that the  make  program runs, it finds/reads the Makefile (providing the specifications)  
and, if necessary, executes the commands for the target named 'updateversion'.

As a good practice, we have one project, and one Makefile, per directory,  so the Makefile will 
already know the name of the project in the current directory, and will be able to pass it to the 
shellscript.

Any clearer?



> > My understanding was that you want a bash script that accepts one argument (the 
> project name), so we run it like '>/updateversion some_project_name'.  It then looks 
> in the folder in which the script is located for 'Makefile', which it opens and checks 
> the header comment '# projectname, ...' to match with the project name arg passed to 
> the script.  Once that is all done, it can then deconstruct the Makefile extracting 
> all the .c and .h filenames and then going and finding each one and changing the 
> header comment as well as noting any anomalies.  Finally, it then changes the header 
> comment in 'Makefile' itself.  All this done with the bash script, nothing to do with 
> make.  However, I'm not sure about that last comment => 'Finally, add a new target to 
> the project's Makefile to update the version number in the C source files and in the 
> Makefile.'  Hang-on, I thought my script was supposed to have already done that!?

Assignment 2 - Q1

photo
From: Nathan S.
Date: Tue 12th May 2020, 12:39pm
Actions: 
        Login-to-reply

 

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

> Hi Nathan,
> 
> "Nathan Scott" <18*1*1*[email protected]*u*e*t*u*a*e*u*a*> wrote:
> 
> > Hi Chris, I have read the other related topics for Q1 and they do not answer my 
> > question.
> > 
> > For Q1, what exactly do you want?  In the assignment spec you indicate a shell script 
> > which accepts one arg (the project name), however in one of the answers on the help 
> > forum you seem to indicate that you want something that runs with 'make updateversion'  
> > , in this case there are no args passed and it is using make.  So updateversion is a 
> > Makefile?
> 
> Running   make updateversion
> 
> requests that the  make  program runs, it finds/reads the Makefile (providing the specifications)  
> and, if necessary, executes the commands for the target named 'updateversion'.
> 
> As a good practice, we have one project, and one Makefile, per directory,  so the Makefile will 
> already know the name of the project in the current directory, and will be able to pass it to the 
> shellscript.
> 
> Any clearer?
> 
> 
> 
> > > My understanding was that you want a bash script that accepts one argument (the 
> > project name), so we run it like '>/updateversion some_project_name'.  It then looks 
> > in the folder in which the script is located for 'Makefile', which it opens and checks 
> > the header comment '# projectname, ...' to match with the project name arg passed to 
> > the script.  Once that is all done, it can then deconstruct the Makefile extracting 
> > all the .c and .h filenames and then going and finding each one and changing the 
> > header comment as well as noting any anomalies.  Finally, it then changes the header 
> > comment in 'Makefile' itself.  All this done with the bash script, nothing to do with 
> > make.  However, I'm not sure about that last comment => 'Finally, add a new target to 
> > the project's Makefile to update the version number in the C source files and in the 
> > Makefile.'  Hang-on, I thought my script was supposed to have already done that!?



Nope, still do not get it, I watched the lecture, but maybe I missed a key concept from it or 
something.  The specification says that 'updateversion' is a 'shellscript', that means a bash script or 
a makefile or something else?  I would have thought 'make updateversion' would be like telling make 
(which I understand is some program) to run 'updateversion' which should have Makefile syntax inside, 
no?  If updateversion is a bash script, how is that going to work?  Can make run bash scripts?   

Assignment 2 - Q1

photo
From: Christopher M.
Date: Tue 12th May 2020, 2:21pm
Actions: 
        Login-to-reply

 

Hi Nathan,

"Nathan Scott" <18*1*1*[email protected]*u*e*t*u*a*e*u*a*> wrote:

> Nope, still do not get it, I watched the lecture, but maybe I missed a key concept from it or 
> something.  The specification says that 'updateversion' is a 'shellscript', that means a bash script or 
> a makefile or something else?  I would have thought 'make updateversion' would be like telling make 
> (which I understand is some program) to run 'updateversion' which should have Makefile syntax inside, 
> no?  If updateversion is a bash script, how is that going to work?  Can make run bash scripts?   

A shellscript is a textfile of bash commands (of almost anything, typically in a one-command-per line format).
We can have bash read and execute those commands by running:

    bash filename

or by making the shellscript (file) directly executable - chmod +x filename
and then running  ./filename

If a textfile is named 'Makefile', its contents will be read by the make program (when you run   make).
It is not a shellscript.
Is it a strictly formatted specification of the relationships between files (such as for a programming project, 
but equally for any other form of files),  and command-sequences to build/create/update files, or to perform any 
sort of action.

Running   'make updateversion'
ask the make program to find a target, named updateversion', in the Makefile and to run its associated commands if 
necessary.

Consider the target named 'clean' in the Makefile provided in the calcmarks example.
We can run   'make clean'
and make invokes the commands associated with the target.

Because there never is a file named 'clean', the target always needs rebuilding, and the commands are thus always 
executed.

If you're still confused by it all, trace what would happen if your shellscript was named   updateversion.sh

??

Assignment 2 - Q1

photo
From: Nathan S.
Date: Tue 12th May 2020, 2:47pm
Actions: 
        Login-to-reply

 

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

> Hi Nathan,
> 
> "Nathan Scott" <18*1*1*[email protected]*u*e*t*u*a*e*u*a*> wrote:
> 
> > Nope, still do not get it, I watched the lecture, but maybe I missed a key concept from it or 
> > something.  The specification says that 'updateversion' is a 'shellscript', that means a bash script or 
> > a makefile or something else?  I would have thought 'make updateversion' would be like telling make 
> > (which I understand is some program) to run 'updateversion' which should have Makefile syntax inside, 
> > no?  If updateversion is a bash script, how is that going to work?  Can make run bash scripts?   
> 
> A shellscript is a textfile of bash commands (of almost anything, typically in a one-command-per line format).
> We can have bash read and execute those commands by running:
> 
>     bash filename
> 
> or by making the shellscript (file) directly executable - chmod +x filename
> and then running  ./filename
> 
> If a textfile is named 'Makefile', its contents will be read by the make program (when you run   make).
> It is not a shellscript.
> Is it a strictly formatted specification of the relationships between files (such as for a programming project, 
> but equally for any other form of files),  and command-sequences to build/create/update files, or to perform any 
> sort of action.
> 
> Running   'make updateversion'
> ask the make program to find a target, named updateversion', in the Makefile and to run its associated commands if 
> necessary.
> 
> Consider the target named 'clean' in the Makefile provided in the calcmarks example.
> We can run   'make clean'
> and make invokes the commands associated with the target.
> 
> Because there never is a file named 'clean', the target always needs rebuilding, and the commands are thus always 
> executed.
> 
> If you're still confused by it all, trace what would happen if your shellscript was named   updateversion.sh
> 
> ??

ok, I get it now, I did not understand the target thing and that you could run a bash script from make.  Basically the 
key is this:
you can run any file from make.  You just put the commands in a target in make will run it, a bash script or anything 
else.
So running this from the terminal: 

make -f xxxx yyyy  

will run the arbitrarily named makefile 'xxxx' with 'make' and output the evaluation of the target 'yyyy'.  All the 
dependencies etc are specified within 'xxxx' for the target 'yyyy'

so for example 'xxxx' could contain:
---------------------------------------------
yyyy : 
        bash a_bash_script arg1 arg2 ....
---------------------------------------------

Assignment 2 - Q1

photo
From: Christopher M.
Date: Tue 12th May 2020, 2:58pm
Actions: 
        Login-to-reply

 

Sounding much better!

"Nathan Scott" <18*1*1*[email protected]*u*e*t*u*a*e*u*a*> wrote:

> ok, I get it now, I did not understand the target thing and that you could run a bash script from make.  Basically the 

Yes, make will run any/many actions, asking bash to run the actions for it.
make has 'no idea' what it is executing, it just asks bash to do it.


> So running this from the terminal: 
> 
> make -f xxxx yyyy  
> 
> will run the arbitrarily named makefile 'xxxx' with 'make' and output the evaluation of the target 'yyyy'.  All the 
> dependencies etc are specified within 'xxxx' for the target 'yyyy'

Yes, though say 'make performs the actions required to build yyyy.
If the commands yyyy don't produce any output (typically to the screen) make will not provide any extra output other than 
reporting it's about to ask bash to run  yyyy

 
> so for example 'xxxx' could contain:
> ---------------------------------------------
> yyyy : 
>         bash a_bash_script arg1 arg2 ....
> ---------------------------------------------

Yes, exactly.  Onward and upward!

Assignment 2 - Q1

photo
From: David M.
Date: Tue 12th May 2020, 7:56pm
Actions: 
        Login-to-reply

 

Assignment 2, Task 1 states that "your shellscript should receive the project's name as a command-line parameter".
It does not say that the project's name is the ONLY parameter.

In my solution the script also receives the complete list of all the project file names as additional parameters.

Assignment 2 Q1

photo
From: Thanh T.
Date: Tue 12th May 2020, 10:42pm
Actions: 
        Login-to-reply

 

- Do the script updateversion print file with different verision from others?
- I have added target updaterversion inside the Makefile, so do we need to submit both 
file???

Thank you so much.

Assignment 2 Q1

photo
From: Christopher M.
Date: Wed 13th May 2020, 6:43am
Actions: 
        Login-to-reply

 

"Thanh Tang" <22*0*0*[email protected]*u*e*t*u*a*e*u*a*> wrote:

> - Do the script updateversion print file with different verision from others?

Yes, the task asks  -  "Your shellscript should also detect and report the problem of any of the 
files having different versions numbers to any others."


> - I have added target updaterversion inside the Makefile, so do we need to submit both 
> file???

Yes.  (Not your fault, but) there's the same answer to this question here:

  https://secure.csse.uwa.edu.au/run/help4407?p=np&a=155&all=y2

Assignment 2 q1

photo
From: Matthew W.
Date: Wed 27th May 2020, 1:19pm
Actions: 
        Login-to-reply

 

Hi,

I am a little confused by the MakeFile requirement in the project.

To my understanding the update version script will be run. This will update the 
comments in the .c and .h files. 

After this has been run successfully, will the makefile only update the comment found 
within the makefile and then recompile the the source files that had been edited by 
the update version script? Or should the makefile have some capability to edit the the 
comments in the .c and .h files rather than just convert the edited .c and .h files to 
executable?

Assignment 2 q1

photo
From: Christopher M.
Date: Wed 27th May 2020, 3:42pm
Actions: 
        Login-to-reply

 

"Matthew Westhoff" <21*8*1*[email protected]*u*e*t*u*a*e*u*a*> wrote:

> To my understanding the update version script will be run. This will update the 
> comments in the .c and .h files. 
> 
> After this has been run successfully, will the makefile only update the comment found 
> within the makefile and then recompile the the source files that had been edited by 
> the update version script? Or should the makefile have some capability to edit the the 
> comments in the .c and .h files rather than just convert the edited .c and .h files to 
> executable?


Hello Matthew,

Your goal is to write a shellscript, that can be invoked by (from within) your Makefile, to update 
the *.c, *.h, and the Makefile itself.

This requirement is very typical - the Makefile (read by the make program) does not, itself, 
perform any of the work, it just determines what needs to be done, and passes each of the action 
lines off to the shell for execution.

There's no requirement to then compile the project's *.c and *.h files.

Assignment 2 q1

photo
From: Jichunyang L.
Date: Wed 27th May 2020, 4:50pm
Actions: 
        Login-to-reply

 

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

> "Matthew Westhoff" <21*8*1*[email protected]*u*e*t*u*a*e*u*a*> wrote:
> 
> > To my understanding the update version script will be run. This will update the 
> > comments in the .c and .h files. 
> > 
> > After this has been run successfully, will the makefile only update the comment found 
> > within the makefile and then recompile the the source files that had been edited by 
> > the update version script? Or should the makefile have some capability to edit the the 
> > comments in the .c and .h files rather than just convert the edited .c and .h files to 
> > executable?
> 
> 
> Hello Matthew,
> 
> Your goal is to write a shellscript, that can be invoked by (from within) your Makefile, to update 
> the *.c, *.h, and the Makefile itself.
> 
> This requirement is very typical - the Makefile (read by the make program) does not, itself, 
> perform any of the work, it just determines what needs to be done, and passes each of the action 
> lines off to the shell for execution.
> 
> There's no requirement to then compile the project's *.c and *.h files.
Hi Chris,
  For Q1, which command I should run? make updateversion $project name or ./updateversion $project 
name?

Assignment 2 q1

photo
From: Christopher M.
Date: Thu 28th May 2020, 9:39am
Actions: 
        Login-to-reply

 

"Jichunyang Li" <22*7*0*[email protected]*u*e*t*u*a*e*u*a*> wrote:

>   For Q1, which command I should run? make updateversion $project name or ./updateversion $project 
> name?

 From the command-line, you do not run either of those.

You need a new target inside your Makefile, so that you can run:

  make updateversion

Your Makefile will already need to know which project (by name) that it can update.

Assignment 2 q1

photo
From: Akhil E.
Date: Sun 31st May 2020, 11:38am
Actions: 
        Login-to-reply

 

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

> "Jichunyang Li" <22*7*0*[email protected]*u*e*t*u*a*e*u*a*> wrote:
> 
> >   For Q1, which command I should run? make updateversion $project name or ./updateversion $project 
> > name?
> 
>  From the command-line, you do not run either of those.
> 
> You need a new target inside your Makefile, so that you can run:
> 
>   make updateversion
> 
> Your Makefile will already need to know which project (by name) that it can update.

Hello Chris,

I have a doubt regarding the structure of the files. 
The shellscript "updateversion" that we write, is it supposed to be present inside the project directory 
along with other *.c, *.h files or is it supposed to be in the parent directory of the project directory.

For now, I have kept my shellscript inside the project folder along with the *.c and *.h files and am able 
to update the version numbers, date and time of the update without accepting any command-line argument. 

Please give some clarity on the hierarchy of the files. So that I will modify my code accordingly to 
reflect those changes. 

Thanks. 
This Page


Program written by: [email protected]
Feedback welcome
Last modified: 11:27am Sep 21 2020