Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: unix script writing  (Read 2993 times)

0 Members and 1 Guest are viewing this topic.

wiggles

  • Guest
unix script writing
« on: December 12, 2008, 06:18:09 PM »

I need help writing this script. Here is the script and my answer. Can someone help me please. This is my first script.



Create an executable script file called “newname” that will perform the followings:
1.   Rename a file upon the user’s request.  If the file exists, prompt the user for confirmation before renaming the file. The screen should prompt the user for
a.   “Name of file you want to rename.”  Use the “\c” escape character.
b.   “New name of file” Use the “\c” escape character.
c.   “File Exist” to avoid overriding a file.
d.   “File $oldname changed to $newname”
e.   “Do you want to rename another file?” If the user selects “yes” the system should refresh the screen and if the user selects “no” the system should exit to the prompt sign.
f.   Refresh the screen to go back to the menu until the user selects the exit option




This is what I wrote

rm -i
Echo     "\c"  Read a file to rename
If file do not exist
   Then
Echo   "\c"Rename the file
   Otherwise
Echo      Ask if the user wants to override file
Echo      Read the user's choice (y/n)
If the answer is yes (y)
   Then
Echo      "Rename the file"
   Otherwise
Echo      Display message ("File Exist")
Fi
Refresh the screen
Exit

Dias de verano

  • Guest
Re: unix script writing
« Reply #1 on: December 13, 2008, 03:17:17 AM »
You have made a good start, you have written out the logic of the script. Now you need to research the shell commands and put them in the correct places in your script, then run it and edit it until it does what you want.