Note that there are some explanatory texts on larger screens.

plurals
  1. POBash Shell Scripting Errors: ./myDemo: 56: Syntax error: Unterminated quoted string
    text
    copied!<p>Could someone take a look at this code and find out what's wrong with it?</p> <pre><code>#!/bin/sh while : do echo " Select one of the following options:" echo " d or D) Display today's date and time" echo " l or L) List the contents of the present working directory" echo " w or W) See who is logged in" echo " p or P) Print the present working directory" echo " a or A) List the contents of a specified directory" echo " b or B) Create a backup copy of an ordinary file" echo " q or Q) Quit this program" echo " Enter your option and hit &lt;Enter&gt;: \c" read option case "$option" in d|D) date ;; l|L) ls $PWD ;; w|w) who ;; p|P) pwd ;; a|A) echo "Please specify the directory and hit &lt;Enter&gt;: \c" read directory if [ "$directory = "q" -o "Q" ] then exit 0 fi while [ ! -d "$directory" ] do echo "Usage: "$directory" must be a directory." echo "Re-enter the directory and hit &lt;Enter&gt;: \c" read directory if [ "$directory" = "q" -o "Q" ] then exit 0 fi done printf ls "$directory" ;; b|B) echo "Please specify the ordinary file for backup and hit &lt;Enter&gt;: \c" read file if [ "$file" = "q" -o "Q" ] then exit 0 fi while [ ! -f "$file" ] do echo "Usage: \"$file\" must be an ordinary file." echo "Re-enter the ordinary file for backup and hit &lt;Enter&gt;: \c" read file if [ "$file" = "q" -o "Q" ] then exit 0 fi done cp "$file" "$file.bkup" ;; q|Q) exit 0 ;; esac echo done exit 0 </code></pre> <p>There are some syntax errors that I can't figure out. However I should note that on this unix system echo -e doesn't work (don't ask me why I don't know and I don't have any sort of permissions to change it and even if I wouldn't be allowed to)</p> <p><s>Bash Shell Scripting Error: "./myDemo ./myDemo: line 62: syntax error near unexpected token <code>done' ./myDemo: line 62:</code>" [Edited]</p> <blockquote> <p><strong>EDIT:</strong> I fixed the while statement error, however now when I run the script some things still aren't working correctly.</p> <ol> <li><p>It seems that in the b|B) switch statement</p> <p><em>cp $file $file.bkup</em> doesn't actually copy the file to file.bkup ?</p></li> <li><p>In the a|A) switch statement </p></li> </ol> <p><em>ls "$directory"</em> doesn't print the directory listing for the user to see ?</p> </blockquote> <pre><code>#!/bin/bash while $TRUE do echo " Select one of the following options:" echo " d or D) Display today's date and time" echo " l or L) List the contents of the present working directory" echo " w or W) See who is logged in" echo " p or P) Print the present working directory" echo " a or A) List the contents of a specified directory" echo " b or B) Create a backup copy of an ordinary file" echo " q or Q) Quit this program" echo " Enter your option and hit &lt;Enter&gt;: \c" read option case "$option" in d|D) date ;; l|L) ls pwd ;; w|w) who ;; p|P) pwd ;; a|A) echo "Please specify the directory and hit &lt;Enter&gt;: \c" read directory if [ ! -d "$directory" ] then while [ ! -d "$directory" ] do echo "Usage: "$directory" must be a directory." echo "Specify the directory and hit &lt;Enter&gt;: \c" read directory if [ "$directory" = "q" -o "Q" ] then exit 0 elif [ -d "$directory" ] then ls "$directory" else continue fi done fi ;; b|B) echo "Specify the ordinary file for backup and hit &lt;Enter&gt;: \c" read file if [ ! -f "$file" ] then while [ ! -f "$file" ] do echo "Usage: "$file" must be an ordinary file." echo "Specify the ordinary file for backup and hit &lt;Enter&gt;: \c" read file if [ "$file" = "q" -o "Q" ] then exit 0 elif [ -f "$file" ] then cp $file $file.bkup fi done fi ;; q|Q) exit 0 ;; esac echo done exit 0 </code></pre> <p>Another thing... is there an editor that I can use to auto-parse code? I.e something similar to NetBeans? </s></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload