The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
help writing this unix script wiggles Shell Programming and Scripting 2 12-12-2008 12:28 PM
writing script in UNIX for copying files in two server REKHA09 Shell Programming and Scripting 4 09-07-2008 02:07 PM
Perl Unix Script Writing Dinkster UNIX for Dummies Questions & Answers 1 02-01-2008 04:09 PM
Writing and executing a script in RTR implementation of UNIX mahajan.anubhav Shell Programming and Scripting 0 03-16-2006 05:20 AM
Need help in writing a unix script pray44u Shell Programming and Scripting 1 03-30-2005 08:15 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-12-2008
wiggles wiggles is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 7
need help writing this unix 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
  #2 (permalink)  
Old 12-12-2008
Ikon's Avatar
Ikon Ikon is offline Forum Advisor  
Registered User
  
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 669
So what have you written/figuredout so far?
  #3 (permalink)  
Old 12-12-2008
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
That looks like a 'clear spec' to me - starting with 'Create a program to ... '

Definitely you should show us what have you tried so far.
  #4 (permalink)  
Old 12-12-2008
wiggles wiggles is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 7
Quote:
Originally Posted by matrixmadhan View Post
That looks like a 'clear spec' to me - starting with 'Create a program to ... '

Definitely you should show us what have you tried so far.

rm -i
read a file to rename
if file exits
then
prompt the user for confirmation ask ? do you want to override this file
if choice is yes (y)
then
ask if the user wants to rename the file
read the user's choice(y/n)
if the choice is yes (y)
the system should refresh the screen
otherwise
the system will exit to the promt sign

  #5 (permalink)  
Old 12-12-2008
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
Please do read the rules of the forum. ( that is the first thing you should do )

Please do not bump up posts if they are not answered.
  #6 (permalink)  
Old 12-12-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,362
Quote:
Originally Posted by wiggles View Post

rm -i
read a file to rename
if file exits
then
prompt the user for confirmation ask ? do you want to override this file
if choice is yes (y)
then
ask if the user wants to rename the file
read the user's choice(y/n)
if the choice is yes (y)
the system should refresh the screen
otherwise
the system will exit to the promt sign


That's a good start: you have converted the spec to pseudo code. Now you have to convert the pseudocode to shell code.

If you are having problems doing that, post the code you have written so far with an explanation of what is not working. Post any error messages you get.
  #7 (permalink)  
Old 12-12-2008
wiggles wiggles is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 7
Quote:
Originally Posted by Ikon View Post
So what have you written/figuredout so far?

rm -i
read a file to rename
if file exits
then
prompt the user for confirmation ask ? do you want to override this file
if choice is yes (y)
then
ask if the user wants to rename the file
read the user's choice(y/n)
if the choice is yes (y)
the system should refresh the screen
otherwise
the system will exit to the promt sign

Closed Thread

Bookmarks

Tags
shell script, shell scripting, unix scripting, unix scripting basics

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:47 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0