LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-13-2010, 01:04 PM   #1
sourkeys
LQ Newbie
 
Registered: Mar 2010
Posts: 11

Rep: Reputation: 0
Programming in Bourne Shell


Coding In the Bourne Shell
Hi there I have a book written in the BASH Shell and I am telnetting to a Server that is using the Bourne Shell

I have this Script and it won't run


$ vi phmenu
"phmenu" 22 lines, 705 characters
#==================================================================
#Script Name: phmenu
#By:
#Date: Feb 22 2010
#Purpose: A menu for the Corporate Phone List
#Command Line: Phmenu
#==================================================================
phonefile=/mnt2/info5068w10/01/test/chap7/corp_phones
loop=y
while [ "$loop" = y ]
do
clear
tput cup 3 12; echo "Corporate Phone Reporting Menu"
tput cup 4 12; echo "=============================="
tput cup 6 9; echo "P - Print Phone List"
tput cup 7 9; echo "A - Add New Phones"
tput cup 8 9; echo "S - Search for Phones"
tput cup 10 9; echo "Q - Quit: "
tput cup 10 19;
read choice | | continue
case $choice in
[Aa]) ./phoneadd ;;
[Pp]) ./phlist1 ;;
[Ss]) ./phonefind ;;
[Qq]) exit ;;
*) tput cup 14 4; echo "Invalid Code"; read choice ;;
esac
done


Any Idea
This is the error

$ ./phmenu
./phmenu: syntax error at line 20: `|' unexpected
 
Old 03-13-2010, 01:14 PM   #2
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Quote:
Originally Posted by sourkeys View Post
read choice | | continue
Remove the space between the '| |' and try if it works then.
 
Old 03-13-2010, 01:15 PM   #3
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Change

read choice | | continue

to

read choice
 
Old 03-13-2010, 01:34 PM   #4
sourkeys
LQ Newbie
 
Registered: Mar 2010
Posts: 11

Original Poster
Rep: Reputation: 0
Okay changing it to just *Read Choice* works,
 
Old 03-14-2010, 10:35 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Moved to programming
 
Old 03-14-2010, 11:49 AM   #6
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
First, scripts *must* have a valid shebang line on the top in order to even qualify as scripts (#!/bin/sh or #!/usr/bin/env bash).

Once you've decided what shell you're exactly using, then we can discuss the most idiomatic method of getting what you want done. The approaches in Bash scripting are *very* different than in POSIX sh.
 
Old 03-14-2010, 12:12 PM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by tuxdev View Post
The approaches in Bash scripting are *very* different than in POSIX sh.
Which are very different from the Bourne shell.
 
  


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: The A-Z of Programming Languages: Bourne shell, or sh LXer Syndicated Linux News 0 03-05-2009 09:30 AM
Bourne Shell Programming help! radmofopunk Programming 27 04-24-2006 03:13 AM
'sh' shell - Actually calls legacy Bourne shell, or uses system default? Dtsazza Linux - Software 1 10-28-2005 09:20 AM
Bourne shell programming noodle123 Programming 3 04-16-2002 03:46 AM

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

All times are GMT -5. The time now is 10:47 PM.

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