Help to troubleshoot and correct


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help to troubleshoot and correct
# 1  
Old 12-01-2010
Help to troubleshoot and correct

Reference (to previous post title): Help_Beginner in Unix

I need assistance in terms of troubleshooting this codes.Though it not complete for the required task,shedding of any idea will be appreciated.
the information about the code is the thread referenced above
Code:
Code:
#!/bin/ksh
touch fileuseranswer
 
echo Username
read i
echo Password
read j
Username="${i}:${j}"
 
if ( ! grep -q $Username /$HOME/PhaseTest/userinfo )  syntax error ( & ) should be [ ]
then
        echo "Wrong Login/Passwd"
        exit 2
fi
 
echo "********Welcome to Groucho Marx University********"
date
QFILE=./questions
# max questions
max=$(sed 's/^[1-9][0-9]*\. /#&/' ${QFILE} | nawk -v FS="\n" -v RS="#" 'END {print NR}')
 
question(){
sed 's/^[1-9][0-9]*\. /#&/' ${QFILE} | awk -v FS="\n" -v RS="#" -v VAR="$1" '(NR==VAR){print$0}' | tee q.tmp
#sed -n '/^'`echo "$1"`'\./,/^d) /p' ${QFILE}
 
while :
do
echo "Enter your choice :"
read b
if ( ! grep "$b"')' q.tmp >/dev/null ) ; then
        echo "Invalid choice"
        rm q.tmp
        RC=1 ; break
else
        rm q.tmp
        grep -v ^$1 fileuseranswer >fileuseranswer.tmp
        echo "$1 $a" >>fileuseranswer.tmp
        cat fileuseranswer.tmp >fileuseranswer
        rm fileuseranswer.tmp
        RC=0 ; break
fi
done
return $RC
}
 
while :
do
print "Enter question number, N for next question, P for previous question or Q for done"
read a
case $a in
        [1-9]*) [[ $a -gt $max ]] && c=$max || c=$a ; question "$c" ;;
        n|N) [[ $c -lt $max ]] && let c+=1 || let c=1 ; question "$c" ;;
        p|P) [[ $c -ge 1 ]] && let c-=1 || let c=$max ; question "$c" ;;
        q|Q) exit 0 ;;
        *) echo "Wrong choice , try again" ;;
esac
done

thanks

---------- Post updated 12-01-10 at 09:11 AM ---------- Previous update was 11-30-10 at 06:31 PM ----------

1)Please explain or show what the correct line of code should be.
2)notice this error highlighted in the terminal when running the code:
Warning: unknown mime-type for "Enter question number, N for next question, P for previous question or Q for done" -- using "application/octet-stream"
Error: no such file "Enter question number, N for next question, P for previous question or Q for done"

how can I resolve this error.


thanks

Last edited by jim mcnamara; 11-30-2010 at 12:59 PM.. Reason: use code tags, added one hint
# 2  
Old 12-01-2010
This appears to be a homework question.

Please post in the appropriate forum using the rules and format for posting homework problems.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Solaris

Error trying to promote ZFS clone - what do I need to do to troubleshoot this?

Steps taken:- 1. Snapshot an existing ZFS filesystem. 2. Created clone from snapshot. 3. Updated files on cloned ZFS filesystem. 4. Snapshot of cloned ZFS filesystem. 5. Attempted to promote clone ZFS and get error message. See below. #zfs list -rt all /rpool/ai NAME ... (2 Replies)
Discussion started by: psychocandy
2 Replies

2. UNIX for Dummies Questions & Answers

How to Troubleshoot the mail sending problem?

I am trying to send a mail through terminal from last week still now I can't able to send it.If there is any resolution Please help me out of this problem.It is very urgent . mail -s "check" upload.xxx@example.com < /root/mail.txt # tail -15 /var/log/maillog Sep 19 16:52:04 edms032... (15 Replies)
Discussion started by: kannansoft1985
15 Replies

3. UNIX for Advanced & Expert Users

Application keep on crashing need to troubleshoot

Hi experts, I am using RHEL as my distro and I have a very important application running on that server. That application is a third party application and I don't have control with the source. That application keeps on crashing or stop like every other day and it doesn't have any traces on... (1 Reply)
Discussion started by: cwiggler
1 Replies

4. Red Hat

How to troubleshoot a 1000 nodes Apache cluster?

Hi all. May I get some expert advice on troubleshooting performance issues of a 1000 nodes Apache LB cluster. Users report slow loading/response of webpages. Different websites are hosted on this cluster for different clients. But all are reporting the same issue. Could you please let me know... (1 Reply)
Discussion started by: admin_xor
1 Replies

5. SuSE

Link Mount Servers Troubleshoot

Hi i was wondering if it's possible for a folder to show files from different folders. Like, folder A to show files from folder B and folder C With Folder A and Folder B being on one server and Folder C being on another server. I Mounted Folder C on the first server (let's call it B2).... (1 Reply)
Discussion started by: hernanimudaniss
1 Replies

6. UNIX for Advanced & Expert Users

High load average troubleshoot

Hi all, hope you can help me. I'm getting high load average and can't find a reason for this, please share your inputs. load average: 7.78, 7.50, 7.31 Tasks: 330 total, 1 running, 329 sleeping, 0 stopped, 0 zombie Cpu0 : 7.0%us, 1.0%sy, 0.0%ni, 23.9%id, 0.0%wa, 38.9%hi,... (4 Replies)
Discussion started by: erick_tuk
4 Replies

7. AIX

troubleshoot

Dear friends, is there any kind of scripts that will damage aix than we can troubleshoot what was the reason :-) just for having fun :-) (2 Replies)
Discussion started by: Vit0_Corleone
2 Replies

8. Solaris

AUTOFS - Troubleshoot directory does not exist

How to troubleshoot autofs /mnt/sum: does not exist in one of the sun server? This was working previously. No issue on NFS mounting. root@devapp # cat /etc/dfs/dfstab share -F nfs -o rw /linxnet/server2 # Master map for automounter # +auto_master /net -hosts ... (7 Replies)
Discussion started by: KhawHL
7 Replies
Login or Register to Ask a Question