LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Scripting (https://www.linuxquestions.org/questions/programming-9/scripting-4175494779/)

pr0xibus 02-13-2014 09:20 AM

Scripting
 
Afternoon

The below script currently asks for 3 pieces of information then runs a command too create a majordomo list.
Code:

#!/bin/bash

# sudo su

cd majordomo/
#pwd

# Entering Details

clear

echo -n "Please Enter List Name : "
read listname

while [[ -e "$listname" ]]
do

        echo "---> File all ready exists"
        echo -n " Please try another name : "
read listname
done

echo -n "Please Enter List Owner : "
read listowner

echo -n "Please Enter Description : "
read description


# Create List

touch $listname

echo -n "Do you want to add users to list y/n : "
read addtoolist

if [ $addtoolist = "y" ];

then

nano $listname

else

/usr/etc/MD-addlist $listowner $listname ""$description"" -f $listname

fi

Now the part i have problem with is the create list part. I can touch $listname fine i can y/n fine, if i enter y and the nano $listname is also fine but when i come too save the $listname with CTRL+x the application will save but the rest of the script wont run. Any help appreciated

Habitual 02-13-2014 09:52 AM

you could just ask for the user to addtoolist in the script and avoid nano altogether?
See http://www.linuxquestions.org/questi...h-bash-806552/ for clues. :)

NevemTeve 02-13-2014 10:09 AM

There is no 'rest of script'. Anyways, it would be polite to use $EDITOR instead of forcing your personal favourite editor.

rtmistler 02-17-2014 02:56 PM

At about your second line of the script, add a line saying
Code:

set -xv
and you'll see the script operations as it progresses through the script. So when you exit your editor, it should show you what the script does next. However as shown, the script does nothing next, it has entered that if-statement and when done with the editor, it will progress to the fi part of the if-statement, and then there's no further script shown.


All times are GMT -5. The time now is 06:04 AM.