Sponsored Content
Full Discussion: help
Top Forums Shell Programming and Scripting help Post 302266096 by diddyp20 on Tuesday 9th of December 2008 12:07:11 PM
Old 12-09-2008
help

hello Im trying to run a script but it doesn't work.
this is the exercise:
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 did! but I have some message error at the line 22 and 23! can someone helps me?

#!/bin/sh

while [ 1==1 ]
do
echo " 1. Select R or r to rename your file"
echo " 2. select E or e to exit the screen"
echo "enter your choice: \c"
read option
case $option in
R|r)echo "name of the file you want to rename: \c"
read filename
echo "enter the new name: \c"
read newname
if [ -f "$newname" ]
then
echo "file already exits"
echo "are you sure you want to move this file to $newname?"
echo "input Y for yes and N for no: Control+C to cancel"
read answer
if [ $answer == [yY] ]
then
mv $file $filename
if [ $? ]
then
echo "Job failed"
else
echo "Job Done"
fi
fi
else
echo "Moving $filename $newname"
mv $filename $newname
sleep 2
if [ $? ]
then
echo "Job failed"
else
echo "Job Done"
fi
#sh rename
fi ;;
E|e) exit 0 ;;
esac
echo
done
exit
 
SIEVESHELL(1)						User Contributed Perl Documentation					     SIEVESHELL(1)

NAME
sieveshell - remotely manipulate sieve scripts SYNOPSIS
sieveshell [--user=user] [--authname=authname] [--realm=realm] [--password=password] [--exec=script] [--execfile=file] server[:port] sieveshell --help DESCRIPTION
sieveshell allows users to manipulate their scripts on a remote server. It works via MANAGESIEVE, a work in progress. The following commands are recognized: list list scripts on server. put <filename> upload script to server. get <name> [<filename>] get script. if no filename display to stdout delete <name> delete script. activate <name> activate script. deactivate deactivate all scripts. OPTIONS
-u user, --user=user The authorization name to request; by default, derived from the authentication credentials. -a authname, --authname=authname The user to use for authentication (defaults to current user). -r realm, --realm=realm The realm to attempt authentication in. -p password, --password=password The password to use when authenticating to server. Note that this parameter can be seen in the process list. Use with caution! -e script, --exec=script Instead of working interactively, run commands from script, and exit when done. -f file, --execfile=file Instead of working interactively, run commands from file file and exit when done. REFERENCES
[MANAGESIEVE] Martin, T.; "A Protocol for Remotely Managing Sieve Scripts", draft-ietf-managesieve-03.txt, Mirapoint, Inc.; May 2001, work in progress. AUTHOR
Tim Martin <tmartin@mirapoint.com>, and the rest of the Cyrus team <cyrus-bugs@andrew.cmu.edu>. perl v5.14.2 2014-06-03 SIEVESHELL(1)
All times are GMT -4. The time now is 11:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy