while writing the script getting an error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting while writing the script getting an error
Prev   Next
# 1  
Old 07-09-2012
while writing the script getting an error

while writing a script m not able to convert string into a number therefore it is not picking the write if condition
pls help
Code:
#!/bin/sh
echo "this game is about selecting number and getting lucky"
echo " the number are 1 2 3 4 5 and 0 to exit"
read $a1
if [ "$a1" = 1 ]; then
                echo "NUMBER IS NOT CORRECT"
elif [ "$a1" = 2 ]; then
                 echo "NUMBER IS NOT CORRECT"
elif [ "$a1" = 3 ]; then
                 echo "NUMBER IS NOT CORRECT"
elif [ "$a1" = 4 ]; then
                echo "NUMBER IS NOT CORRECT"
elif [ "$a1" = 5 ]; then
                echo "NUMBER IS NOT CORRECT"
else
        echo "you win"
fi


Last edited by joeyg; 07-09-2012 at 11:20 AM.. Reason: Please wrap data and sripts with CodeTags
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Getting compilation error while writing standalone for ddi_get8

Hi All, I have already posted a thread regarding ddi_regs_map_setup solaris system call guidance. https://www.unix.com/programming/171907-need-guidance-using-ddi_regs_map_setup-solaris-system-call.html I am writing a standalone to use this system call. Below is my partial standalone... (6 Replies)
Discussion started by: vijayrajen
6 Replies

2. HP-UX

Please help me writing this script

I work on a production server. I have to check one folder named "spool" and delete files under it , which are more than 5 minutes old. I do it manually by writing two commands. touch -t YYMMDDHHMMSS /tmp/timeinfo find /spool ! -newer /tmp/timeinfo -exec rm -rf {} \; I want to... (4 Replies)
Discussion started by: manalisharmabe
4 Replies

3. Red Hat

writing a script

Dear Madam/Sir Who can help me with writing a script doing the following? 1- Read names of files (only files with special name format let say initially they have the same file name start like TT*) 2- Then create an empty files with the same names have been read in step one but with extension... (1 Reply)
Discussion started by: m.nageeb
1 Replies

4. HP-UX

DVD writing I/O Error on HP-UX

Hello, when I executed this command: root@server:/opt/ignite/lbinia> growisofs -Z /dev/rdsk/c1t2d0=/PA.iso I get the following output and error: Executing 'builtin_dd if=/PA.iso of=/dev/rscsi/c1t2l0 obs=32k seek=0' :-: I/O error Anyone have any idea what is happeneing? Here is... (1 Reply)
Discussion started by: LinuxRacr
1 Replies

5. Shell Programming and Scripting

Help in writing a script

Hey everyone Can anyone please write me a script to display numbers in descending order dynamically i.e if the user enter a number say 100 then the output should be like 100 99 ....so on till 0 I tried using the logic as for ((i =1; i<=100; i--) but the it goes into a infinite loop since even the... (7 Replies)
Discussion started by: icchi
7 Replies

6. Shell Programming and Scripting

error in file writing in crontab

Hi , I have a crontab job that is trying to write a file and the read it . But the crontab is not able to create any file . But when i run the script as shell then it runs fine . could you tell me what i am missing here . Here is the script cat Tablespace_Monitor_ATG #!/bin/ksh... (2 Replies)
Discussion started by: capri_drm
2 Replies

7. Shell Programming and Scripting

Writing to standard error

Hi, I want to redirect the standard output to standard error whenever an error occurs for ex if then echo right else echo wrong fi I want to redirect the wrong to stderror .Adding a line 1>&2 will do that or is additional code to be added.How can i verify whether the output... (2 Replies)
Discussion started by: padmisri
2 Replies

8. Shell Programming and Scripting

Writing the script

I whant write the script of monitoring my servers on night-active users. He must loging all user actions, when user login, when logout, when he do su etc. But i don't know with what to begin :( How command i can use? awk, sed, last And what logs i can use too? /var/log/messages, /var/log/secure... (1 Reply)
Discussion started by: jess_t03
1 Replies

9. UNIX for Dummies Questions & Answers

Writing to Standard Error

Hi. I'm working on a project for a class, and there's one part of the project that is confusing me. It's a compression and decompression project, and after we write our code for compression, we need to write to standard error. (1) Size of original file (number of characters read... (1 Reply)
Discussion started by: sjung10
1 Replies

10. UNIX for Dummies Questions & Answers

help for writing a script

Hi, I need help writing a unix script to change the time in the server automatically when it reaches a specified time. Only on the 14th of april, when the time becomes midnight (00:00:00), I need the server to change the time automatically to 23:30:00 and start working on as usual with a... (2 Replies)
Discussion started by: amodha
2 Replies
Login or Register to Ask a Question
LR_ENVIRONMENT.IN(1)					  LogReport's Lire Documentation				      LR_ENVIRONMENT.IN(1)

NAME
lr_environment - Export Lire configuration in shell script form SYNOPSIS
eval `lr_environment` DESCRIPTION
The lr_environment command is used to import the Lire configuration in Lire shell scripts. All of Lire configuration variables will be written in a format that can be evaled by the shell. Shell scripts don't usually have to use that command, since it is done by the defaults file sourced by each command. The old names used by when the configuration was done in shell script are also exported by this script for backward compatibility. AUTHOR
Francis J. Lacoste <flacoste@logreport.org> VERSION
$Id: lr_environment.in,v 1.12 2006/07/23 13:16:33 vanbaal Exp $ COPYRIGHT
Copyright (C) 2003 Stichting LogReport Foundation LogReport@LogReport.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program (see COPYING); if not, check with http://www.gnu.org/copyleft/gpl.html. Lire 2.1.1 2006-07-23 LR_ENVIRONMENT.IN(1)