Jump to content

Need Help


diddyp20

Recommended Posts

hello

Im working on an exercise,

and I don't succeed...

here 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

Note:  The script must be demonstrated in class to make sure that it works.

 

thanks so much

 

Link to comment
https://forums.phpfreaks.com/topic/136161-need-help/
Share on other sites

here is what I did and Im completely wrong

 

 

#

#

#

echo "      ********************************************************* "

echo "      * 1. Select R or r to rename your file                  * "

echo "      * 2. Select E or e to exit the screen                  * "

echo "      ********************************************************* "

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 " New name of file : \c"

  read file

  if test -r "$filename"

then

echo "do you want to rename this file?"

echo "input Y for yes and N for no: \c"

read answer

elif test "$answer" = Y

then

mv $filename $file

else

sh newname

fi ;;

  E|e) exit 0 ;;

esac

echo

exit 0

 

Link to comment
https://forums.phpfreaks.com/topic/136161-need-help/#findComment-710194
Share on other sites

Why is this posted in third party PHP scripts?

 

What language is that?  Looks like you are trying to mix Basic with PHP.

 

Yeah I know, what is that?  Doesn't look like PHP to me.

 

here is what I did and Im completely wrong

 

Why are you completely wrong?  What happened when you ran it?

Link to comment
https://forums.phpfreaks.com/topic/136161-need-help/#findComment-710583
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.