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
shell script error alias_juju UNIX for Dummies Questions & Answers 2 07-02-2008 01:05 PM
Shell Script Error jazz8146 UNIX for Dummies Questions & Answers 0 04-23-2008 07:38 AM
Shell script run error ksh: not found nz80qy Shell Programming and Scripting 3 03-25-2008 10:57 AM
awk Shell Script error : "Syntax Error : `Split' unexpected Herry UNIX for Dummies Questions & Answers 2 03-17-2008 11:16 AM
error in shell script jalpan.pota UNIX for Dummies Questions & Answers 2 05-18-2007 09:14 AM

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

Join Date: Nov 2008
Posts: 1
SHELL SCRIPT error

Hi I am a new member,can any one help me


#!/bin/sh
# 'clear'
for i in $(seq -w 15 37)
do
#echo $i
string1= wget --dns-timeout=0.001 http://napdweb${i}.eao.abn-iad.ea.co.../test/test.jsp;
if [ "$string1" = "$Resolving napdweb${i}.eao.abn-iad.ea.com...failed connection timed out." ];
then
echo "May be napdweb${i}.eao.abn-iad.ea.com...has hung, please restart."
else
echo "Everything is good and fine"
fi
done
~


After the wget command is executed,i assigned that string to another string called string1. so in the next step when that string1 is equal to a particular string as i given in program, it should display a msg as server is down please restart otherwise else part should be displayed.I dont know why my logic is not running can any one solve it plssssssss
  #2 (permalink)  
Old 11-17-2008
yongitz yongitz is offline
Registered User
  
 

Join Date: Apr 2008
Location: Philippines
Posts: 68
Hi! your variable is set incorrectly and your logic is a bit wrong. Try changing your script into this:
Code:
wget --dns-timeout=0.001 http://napdweb${i}.eao.abn-iad.ea.com:8000/webcore/test/test.jsp -o testme.log
string1=`grep failed testme.log`
**your test here**

Hope that helps.
  #3 (permalink)  
Old 11-17-2008
Lakris Lakris is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 240
Hi,
to assign the output of wget to string1 You should use this insted:
Code:
string1=$(wget --dns-timeout=0.001 http://napdweb${i}.eao.abn-iad.ea.co.../test/test.jsp)
or backticks ` `insted of $() will be fine too. But are You sure the returned string is the best way to determine failure/success? You will get several lines of output depending on what's gone wrong. Try using wgets return value instead, $?. A value of 0 is usually success, 1 or higher is failure.

/Lakris



/Lakris
  #4 (permalink)  
Old 11-17-2008
yongitz yongitz is offline
Registered User
  
 

Join Date: Apr 2008
Location: Philippines
Posts: 68
Quote:
Originally Posted by Lakris View Post
Hi,
to assign the output of wget to string1 You should use this insted:
Code:
string1=$(wget --dns-timeout=0.001 http://napdweb${i}.eao.abn-iad.ea.co.../test/test.jsp)
I doubt if it will work with wget(assigning the output of wget to string1), at least with my box, I didn't get any output..

Code:
yongitz@wolfgang:~$ string1=$(wget --dns-timeout=0.001 http://napdweb${i}.eao.abn-iad.ea.com:8000/webcore/test/test.jsp)
--14:18:38--  http://napdweb.eao.abn-iad.ea.com:8000/webcore/test/test.jsp)
           => `test.jsp'
Resolving napdweb.eao.abn-iad.ea.com... failed: Connection timed out.
yongitz@wolfgang:~$ echo $string1

yongitz@wolfgang:~$
Or I am just missing something...
Sponsored Links
Closed Thread

Bookmarks

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 09:49 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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