LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-13-2014, 09:20 AM   #1
pr0xibus
Member
 
Registered: Apr 2004
Location: Scotland
Distribution: Slackware
Posts: 215

Rep: Reputation: 44
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
 
Old 02-13-2014, 09:52 AM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
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.
 
Old 02-13-2014, 10:09 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,868
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
There is no 'rest of script'. Anyways, it would be polite to use $EDITOR instead of forcing your personal favourite editor.
 
Old 02-17-2014, 02:56 PM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Scripting the Linux desktop, Part 2: Scripting Nautilus LXer Syndicated Linux News 0 02-17-2011 04:02 AM
Firefox Scripting Add-on (Scripting HTML / Javascript inside Firefox) linuxbeatswindows Programming 1 09-18-2009 10:09 PM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
Need help scripting Tamara Programming 1 06-05-2005 03:18 PM
Scripting help JediMasterTux Linux - Newbie 2 07-13-2004 01:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration