I need help with windows shell scripts.

October 5, 2010 at 20:35:19
Specs: Windows Vista
I have these 3 scripts to write as a part of HW lab assignment. I really suck at this class, and its not part of my major but was required to take it.

Anyway here they are

Lab Exercises:

1) Restore the Exploring Word directory and then write a script to count the number of files in your Exploring Word directory that start with Chapter.

* Save the script as countFiles.cmd and upload it to the For Loop drop box.

2) Factorial is a mathematical procedure defined by the following formula:

n! = n (n-1) (n-2) …. (1)

For example:

4! = (4)(3)(2)(1) = 24

Write a script that will do the following:

* Allow the user to enter one positional parameter.

* Display an error message if the parameter is greater than 12. The shell can not handle n! for n greater than 12, due to the limitations of a 32-bit machine.

* If the number is 12 or less use a for loop to compute the value of n! where n is the number that was entered.

* Your script should display a message like: 3 factorial equals 6

* Name your script factorial.cmd.

3) Write a script that updates the renFor script to rename each file that starts with Chapter by changing the string Practice to Exercise within the file name.

* You will need to use a substring operation to isolate the file name from the path.

* Then you’ll need a substitution operation to replace the string Practice with Exercise.

* Save the script as renForSub.cmd


See More: I need help with windows shell scripts.

Report •


#1
October 5, 2010 at 21:14:30
Beats me why your instructor wants to call a BAT a .CMD, but anyway, start on getting the factorial using a FOR loop.


=====================================
Helping others achieve escape felicity

M2


Report •

#2
October 7, 2010 at 06:28:04
Beats me why your instructor wants to call a BAT a .CMD
I prefer to have my Command Prompt scripts with an extension of CMD. That way I know my Command Prompt-only logic will not attempt to run on a Win9X or DOS box.

How To Ask Questions The Smart Way


Report •

#3
October 7, 2010 at 09:24:41
Hi R2,

That seems like a good reason.

Prob is, [You may recall a caes a few months ago.] sometimes they go egg-shaped.


=====================================
Helping others achieve escape felicity

M2


Report •
Related Solutions


Ask Question