check my first shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting check my first shell script
# 1  
Old 05-14-2007
check my first shell script

I have written the below script to determine whether a string is palindrome or not ?
But its not working, any help to debug it ?

I am new to this forum but when I searched for my question, I found that many people refused to answer this question thinking that its Homework question, Therefore I want to make it clear that its not a Homework , I am learning shell scripting on my own.

If you can still help me, thank you much.
--------------------------------------
#!/bin/sh
var="mom"
var1=`echo $var|rev`
if [$var -eq $var1];then
echo "$var is palindrom"
else
echo "$var is not palindrom"
fi
# 2  
Old 05-14-2007
Code:
#!/bin/sh
var="mom"
var1=`echo $var|rev`
if [ $var = $var1 ]; then
   echo "$var is palindrom"
else
   echo "$var is not palindrom"
fi

P.S. pls use vB Codes when posting code snippets.
# 3  
Old 05-14-2007
Sorry, will take care from next time.

Quote:
Originally Posted by vgersh99
Code:
#!/bin/sh
var="mom"
var1=`echo $var|rev`
if [ $var = $var1 ]; then
   echo "$var is palindrom"
else
   echo "$var is not palindrom"
fi

P.S. pls use vB Codes when posting code snippets.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell Script to check a file

I'm required to write a simple shell script that when it runs it writes the output which is a simple barcode to a tmp flat file which I can do the bit I'm struggling with... The next time it runs I need to check the tmp output file to see if that barcode is in the output file and if it is send... (5 Replies)
Discussion started by: worky
5 Replies

2. UNIX for Dummies Questions & Answers

Need shell script to check file

Hi Experts, I am not good in writing script. Just stared.I am looking for shell script to check following parameters. 1) Number of files on remote Linux SUSE server.- Any directory and sub directory. 2) I should define number of files in script. Files should be variable. 3) Age of... (2 Replies)
Discussion started by: ApmPerfMonitor
2 Replies

3. Shell Programming and Scripting

Shell script to check for a Occurance

Hi All, I am very new to this forum and Unix too... I need to create a script which has to check for a file's occurrence in a specified location for 4 hours and send out a email when ever the file has arrived. It should also have a timer to send the status message for every 15 minutes if the... (2 Replies)
Discussion started by: shandivi
2 Replies

4. Shell Programming and Scripting

Bash shell script to check if script itself is running

hi guys we've had nagios spewing false alarm (for the umpteenth time) and finally the customer had enough so they're starting to question nagios. we had the check interval increased from 5 minutes to 2 minutes, but that's just temporary solution. I'm thinking of implementing a script on the... (8 Replies)
Discussion started by: hedkandi
8 Replies

5. Shell Programming and Scripting

help on shell script to check line

Hi Scripting Gurus, Can someone help to transform the below logic into a shell script, might be easy for some of you. I have a file with below text, I need if the line has the ":" and the above to it is not a blank line should print " <text>: is incorrect format" Apple: ... (3 Replies)
Discussion started by: usyseng
3 Replies

6. Shell Programming and Scripting

perl script to check if empty files are created and delete them and run a shell script

I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell... (2 Replies)
Discussion started by: hussa1n
2 Replies

7. Shell Programming and Scripting

IP check with shell script

hi guys ..newbie here i would like to create a simple script tat will detect wether the machine has IP or not ... but it seems that my script doesnt really work it kept rebooting... i set this script during boot so that it will check else it will reboot it a shell script thou... ... (5 Replies)
Discussion started by: bladez
5 Replies

8. Shell Programming and Scripting

script check the users in SHELL ?

could you please find a solution for this script that checks if any of a list of users given on the command line is logged in. For each user the script should say whether this user is logged in or not. The script prints an error message if no parameter is given. And ask the user to enter a name... (3 Replies)
Discussion started by: anything
3 Replies

9. Shell Programming and Scripting

Check EOF in shell script

Hi, I need to check whether one file has EOF or not. There's one daemon in our system, which will pick the files FTPed to us. However, sometimes the daemon picks the file before FTP is finished. So I'm planning to add some checking of EOF on the FTPed files in the shell script. Could... (8 Replies)
Discussion started by: ideazhcy
8 Replies

10. Shell Programming and Scripting

check in unix shell script so that no one is able to run the script manually

I want to create an automated script which is called by another maually executed script. The condition is that the no one should be able to manually execute the automated script. The automated script can be on the same machine or it can be on a remote machine. Can any one suggest a check in the... (1 Reply)
Discussion started by: adi_bang76
1 Replies
Login or Register to Ask a Question