Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.