The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Linux Shell Question: how to print the shell script name ? meili100 UNIX for Dummies Questions & Answers 3 07-01-2008 01:55 PM
shell script question tselvanin Shell Programming and Scripting 2 08-28-2007 09:53 PM
A shell script question surjyap Shell Programming and Scripting 2 11-24-2005 05:48 AM
Simply shell script question frustrated1 Shell Programming and Scripting 8 07-03-2005 02:22 AM
BASH shell script question ewarmour Shell Programming and Scripting 3 05-24-2002 05:10 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-05-2008
jbou1087 jbou1087 is offline
Registered User
  
 

Join Date: May 2008
Posts: 2
Shell script question

Hello, i am doing a project for school and i cannot figure out whats wrong with my 2 programs they dont seem to work at all.

the first program is called isprime and naturally it checks to see if hte number is prime or not

here is my code:

#!/usr/bin/bash

num=$1

echo you typed [$num]
if [ $num -gt 0 ] ; then
for mrv in `seq 2 $(($num/2))` ; do
modulo=$(( $num % $mrv))
if [ $modulo -eq 0 ] ; then
echo "is not prime"
exit
fi
done
else
echo ERROR
fi


my second program is called unscramble its supost to take in text and unscramble it to a word

#!/usr/bin/bash

word=$1
len=${#word}
cmd="egrep -i \"\<[$word]{$len}\>\" /usr/dict/words"

lp=0
while [ $lp -lt $len ] ; do
cmd="$cmd|grep ${word:$lp:1}"

ltr=${word:$lp:1}
dbl=`echo $word|egrep "($ltr).*\1"`
if [ -n "$dbl" ] ; then
echo $ltr is a double
fi

lp=$((lp+1))
done
eval "$cmd"



all this programming is very new to me and i can get confused easily any help would be great thank you
  #2 (permalink)  
Old 05-05-2008
jbou1087 jbou1087 is offline
Registered User
  
 

Join Date: May 2008
Posts: 2
Nevermind i solved my problem.

But i do have one other question, how can i disable the shell errors, i created my own, and i just watn to not displaythe shell errors.

Thanks
  #3 (permalink)  
Old 05-06-2008
namishtiwari namishtiwari is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2007
Location: Bangalore
Posts: 377
Quote:
Originally Posted by jbou1087 View Post
Nevermind i solved my problem.

But i do have one other question, how can i disable the shell errors, i created my own, and i just watn to not displaythe shell errors.

Thanks
redirect it to
Code:
2>/dev/null
Sponsored Links
Closed Thread

Bookmarks

Tags
bash, bash eval, eval

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:41 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0