Editing a file within a script and then continueing
Hi there,
Can someone please help out with this. I am running a script and want to add the option of viewing and amending a file, then continue to the script. If the user enters y, the file will be opened for editing. When editing is done, I want to continue the script. Pressing n will continue the script, I have .. read -p "****** To change the file press y or n to continue" choice echo "" case "$choice" in y|Y ) vi $statfile ;; n|N ) echo "no";; * ) ;; esac echo "contine script" Many thanks |
Find the bash file as below:
=============================== #!/bin/bash trap "" 2 20 while : do clear echo 1. open file echo 2. exit read option; case $option in 1) vi test.txt ;; 2) exit ;; esac done ================================== I hope this will help you. |
Thanks for that.
After the filehas been opened for editing, I need to continue with the rest of the script. How do I do that ? Thanks |
SmurfGGM,
I didnt get you. are you calling this script from other script? What I was understand, When you complete with editing file, you should be back to menu. |
When I finish editing the file that is called by the script, I want the script to continue running.
Thanks |
So where are you stuck? All seems ok.
Just try it, and let's know if you have any issue: Code:
#!/bin/bash |
Thanks
I get read: -p: no coprocess Continue script... |
ah i got it working with ..
read resp1?"To change the file press y or n to continue: " case $resp1 in y|Y) vi $statfile echo "File editing done" ;; n|N) echo "File was not edited.";; *) ;; esac echo "Continue script..." Thanks for your time |
Script is running fine on my system, so I guess you made some mistake. Once invoke the script with -xv option to see that where it goes wrong, as:
Code:
~$ bash -xv scriptname.sh Code:
#!/bin/bash |
All times are GMT -5. The time now is 05:24 AM. |