The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
If Statement Problem.. LinuxRacr Shell Programming and Scripting 2 02-26-2008 08:47 PM
Case statement problem gzs553 UNIX for Advanced & Expert Users 6 11-14-2006 12:24 PM
if statement problem djt0506 UNIX for Dummies Questions & Answers 4 12-04-2005 04:16 PM
problem with an IF statement hcclnoodles Shell Programming and Scripting 2 04-17-2003 07:53 AM
if statement problem coughlin74 UNIX for Dummies Questions & Answers 1 09-27-2001 01:31 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-12-2008
cleansing_flame's Avatar
Registered User
 

Join Date: Nov 2007
Location: NYC
Posts: 37
Stumble this Post!
problem with if statement equality

Here's my script:

/bin/script.sh

echo "hey __, don't forget the password is "kazlo""
echo "insert the name of your file in the next line, be very specific"
read var1
vartest=`find . | grep "$var1"`
echo $vartest
echo "you sure this is the right file? answer next line with (y/n)"
read var2

if test [$var = "y"]
then
scp "$vartest" username@targetserver.org:/Users/username/
echo hopefullyworks
fi



it just skips over my if statement
this is really simple i'm sure but I can't get it to work
any help appreciated
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-12-2008
Registered User
 

Join Date: Nov 2007
Posts: 55
Stumble this Post!
Either

if [ $var = "y" ]
then
scp "$vartest" username@targetserver.org:/Users/username/
echo hopefullyworks
fi

Or

if test $var = "y"
then
scp "$vartest" username@targetserver.org:/Users/username/
echo hopefullyworks
fi

Both test and [] are not required then if u use [] then give space after and beore [ and ]
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0