Script Conversion To Ubuntu 8.10


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script Conversion To Ubuntu 8.10
# 8  
Old 04-13-2009
The comments are part of the code.
# 9  
Old 04-13-2009
I am definately learning! Thanks!! I redid it and your comment about the man pages has help me a bit in cleaning up some of the ping portion but the [-n "$4" ] is still giving me fits. Thanks for your patience. Dale
# 10  
Old 04-13-2009
Quote:
Originally Posted by gbxfan
I am definately learning! Thanks!! I redid it and your comment about the man pages has help me a bit in cleaning up some of the ping portion but the [-n "$4" ] is still giving me fits. Thanks for your patience. Dale

There is only one script; there should only be one pair of [code] tags.

Now, to repeat the questions I asked earlier:

Which part is giving you problems? What problems is it giving you? If you get error messages, please post them.

Have you tried executing just the problem parts (substituting reasonable values for the variables)?

Note that the -a operand is problematic; it is better to use:

Code:
if [ -n "$WASDOWN" ] && [ -z "$ISDOWN" ]; then

rather than:

Code:
if [ -n "$WASDOWN" -a -z "$ISDOWN" ]; then

# 11  
Old 04-13-2009
Ah, ok. I have went back in and I think the code is now better. The part giving me the problem is:

#[PING PORTION]
sping()
{
NAME=$1
IP=$2
ROUTER=$3
if [ -n "$4" ]; then
COUNT=$4
else
COUNT=1
fi
if ping $IP 56 $COUNT | grep -s "100% packet loss"; then
if ping $ROUTER 56 $COUNT | grep -s "100% packet loss"; then
echo "$NAME $IP $ROUTER (down because route to it is down)"
echo "$NAME $IP $ROUTER (down because route to it is down)" 1>&2

and at the moment its the if statement with < if [ -n "$4"]; then >

Any coding ideas on that? Thanks.
# 12  
Old 04-13-2009
Quote:
Originally Posted by gbxfan
Ah, ok. I have went back in and I think the code is now better. The part giving me the problem is:

Why are there no [code] tags?
Quote:

#[PING PORTION]
sping()
{
NAME=$1
IP=$2
ROUTER=$3
if [ -n "$4" ]; then
COUNT=$4
else
COUNT=1
fi
if ping $IP 56 $COUNT | grep -s "100% packet loss"; then
if ping $ROUTER 56 $COUNT | grep -s "100% packet loss"; then
echo "$NAME $IP $ROUTER (down because route to it is down)"
echo "$NAME $IP $ROUTER (down because route to it is down)" 1>&2

and at the moment its the if statement with < if [ -n "$4"]; then >

Any coding ideas on that? Thanks.

And I repeat yet again:

What problems is it giving you? If you get error messages, please post them.

Have you tried executing just the problem parts (substituting reasonable values for the variables)?
And those ping commands do not look like GNU ping commands. Did you read the man page?

Last edited by cfajohnson; 04-13-2009 at 07:33 PM..
# 13  
Old 04-13-2009
Here is the error I get when the script is run. I have again attempted the code tags and think its better (I hope).

OUTPUT
+ read NAME IP ROUTER
+ sping albany1 xx.xx.xx.xx xx.xx.xx.1
+ NAME=albany1
+ IP=xx.xx.xx.xx
+ ROUTER=xx.xx.xx.1
+ '[-n' ']'
ping_servers.sh: line 256: [-n: command not found
+ grep '(down'
+ COUNT=1
+ ping xx.xx.xx.xx -c 1
+ grep -s '100% packet loss'
+ echo 'albany1 xx.xx.xx.xx xx.xx.xx.1 (up)'
+ echo 'albany1 xx.xx.xx.xx xx.xx.xx.1 (up)'
albany1 xx.xx.xx.xx xx.xx.xx.1 (up)
# 14  
Old 04-13-2009
Quote:
Originally Posted by gbxfan
Here is the error I get when the script is run. I have again attempted the code tags and think its better (I hope).

There are no [code] tags.
Quote:

OUTPUT
+ read NAME IP ROUTER
+ sping albany1 xx.xx.xx.xx xx.xx.xx.1
+ NAME=albany1
+ IP=xx.xx.xx.xx
+ ROUTER=xx.xx.xx.1
+ '[-n' ']'
ping_servers.sh: line 256: [-n: command not found

There must be a space after '['.
Quote:
+ grep '(down'
+ COUNT=1
+ ping xx.xx.xx.xx -c 1
+ grep -s '100% packet loss'
+ echo 'albany1 xx.xx.xx.xx xx.xx.xx.1 (up)'
+ echo 'albany1 xx.xx.xx.xx xx.xx.xx.1 (up)'
albany1 xx.xx.xx.xx xx.xx.xx.1 (up)
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 ouput conversion

Hi All, I am trying to print all the packages info in solaris 11 using below script. #!/usr/bin/env bash pkginfo -l | egrep '(BASEDIR|NAME|VERSION)' | awk '{print}' > /tmp/cp1 /usr/bin/nawk -F: ' {for (i=1; i<=NF; i++) {gsub (/^ *| *$/, "", $i) ... (5 Replies)
Discussion started by: sravani25
5 Replies

2. UNIX for Beginners Questions & Answers

powershell script to unix shell script conversion.

Here is a powershell script to use restful API to create ticket in our ticketing tool. Can anyone please convert it to a shell script sothat, I can run it in Unix servers, below is the code: $body = @{ Customer= ''test' Summary= 'test summary' Impact= '4-Minor/Localized' ... (2 Replies)
Discussion started by: pandeybhavesh18
2 Replies

3. Shell Programming and Scripting

Batch to shell script conversion

Hi All, I have a small tool which is currently configured in batch scripts only. But my need is to run it on Linux platform, so I have been trying to convert a batch script to shell script. below is the batch script: @echo off IF "%1"== "" GOTO ARGERR REM UPDATE THESE PROPERTIES TO... (2 Replies)
Discussion started by: sukhdip
2 Replies

4. Shell Programming and Scripting

Conversion of Perl Script to Shell Script..

Hi Guys I am having a perl script that fetches exclude list from a unix client and I trying it to convert it to shell script but I am having issues please help me... #!/usr/bin/perl use strict; use warnings; use Getopt::Std; # To turn on debuging (i.e. more information) specify... (29 Replies)
Discussion started by: Pawan Ramnani
29 Replies

5. Shell Programming and Scripting

Text to XML conversion using script

Hi I have a file in the format with so many records DB2 Universal JDBC Driver Provider,wdialdcsq,New JDBC Datasource,jdbc/wdialdcsq,,dcsqdb2n,cldrdgw1.is.chrysler.com,2998,DB2,10,1,180,0,1800 i need to convert all these into <DataSource name="wdialODDC" maxConnection="10" minConnection="0 "... (1 Reply)
Discussion started by: mskalyani9
1 Replies

6. Shell Programming and Scripting

Shell script for CSV conversion

thanks for allowing me join your forum i have an output of linux command "who" which provides following details..... CURRENT USER/ACCT INFO 17:31:36 up 4:49, 4 users, load average: 0.03, 0.04, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root :0 - 12:59 ?xdm? 4:54 0.02s /bin/sh /usr/bi... (1 Reply)
Discussion started by: ayyappancheta
1 Replies

7. AIX

Need timestamp conversion shell script !!

Can anyone provide me with a ksh or bash script which will accept a timestamp (format is YYYY-MM-DD-HH24.Mi.Ss) and time offset (in hours). The output will be (timestamp passed - time offset passed deducted from it) in the same YYYY-MM-DD-HH24.Mi.Ss format. Basically I am trying to convert the... (1 Reply)
Discussion started by: shibajighosh
1 Replies

8. Shell Programming and Scripting

Encoding conversion in PERL script

I have oracle 9i database installed with UTF-8 Encoding. I want a perl script that converts unicode to utf8 before commiting in database and utf8 to unicode when retreiving from database For example : the word Ïntêrnatïônàlîzâtion has to be stored in database as Internationalization and when retreived... (6 Replies)
Discussion started by: vkca
6 Replies

9. Windows & DOS: Issues & Discussions

unix script and unix2dos conversion

Hi, I am a newbie and do not have much experience using unix. But I have been trying to understand it. I found the following unix script typeset -i n=0 while do sleep 5 echo "${n}:Fluent is running...." n=${n}+1 done I have the following doubts: 1) In the first line - I am aware... (1 Reply)
Discussion started by: karthiksrao
1 Replies

10. Shell Programming and Scripting

shell script conversion to binary

My question is: i have a script called getevent to run i just call ./getevent can i convert this to make it binary executable and not letting my clients open it and see the code.??:( I am using Solaris 8. (3 Replies)
Discussion started by: bcheaib
3 Replies
Login or Register to Ask a Question