diddyp20 Posted December 9, 2008 Share Posted December 9, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/136161-need-help/ Share on other sites More sharing options...
diddyp20 Posted December 9, 2008 Author Share Posted December 9, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/136161-need-help/#findComment-710194 Share on other sites More sharing options...
revraz Posted December 9, 2008 Share Posted December 9, 2008 What language is that? Looks like you are trying to mix Basic with PHP. Sounds like you didn't really pay attention during PHP class. Quote Link to comment https://forums.phpfreaks.com/topic/136161-need-help/#findComment-710499 Share on other sites More sharing options...
Maq Posted December 9, 2008 Share Posted December 9, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/136161-need-help/#findComment-710583 Share on other sites More sharing options...
diddyp20 Posted December 9, 2008 Author Share Posted December 9, 2008 it is Unix Quote Link to comment https://forums.phpfreaks.com/topic/136161-need-help/#findComment-710587 Share on other sites More sharing options...
Maq Posted December 9, 2008 Share Posted December 9, 2008 Unix what, assembly? Doesn't look like it. Still, why is it in third Party PHP scripts? Quote Link to comment https://forums.phpfreaks.com/topic/136161-need-help/#findComment-710594 Share on other sites More sharing options...
tomfmason Posted December 9, 2008 Share Posted December 9, 2008 it is Unix It is bash. OP: you should look over http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html Quote Link to comment https://forums.phpfreaks.com/topic/136161-need-help/#findComment-710604 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.