Shell script guru


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script guru
# 1  
Old 10-29-2013
Scissors Shell script guru

Hey Gurus,
Need help to modify the shell script. I am really new in the Linux/Unix world and dont familiar with shell scripting. SO bascially my script is running a ( curl ) with some endpoints and returning HTTP status code.
Now i have a 50 different endpoints and cant make each and individual file for those endpoints. So now i am thinking to pass the CURL as argument. I have tried so many things but didnt work. please gurus help me to figure it out this.
MY SCRIPT

Code:
#!/bin/sh

#### Errors ####
#200X   OK
#300X   WARNING
#400X   WARNING
#500X   CRITICAL
#Else   UNKNONE
################

#Set Email
EMAIL=""


OUT_STATUS="500"


OUT_MSG="$(curl -H "Accept: application/json" -H "Content-Type: application/json" -H "X-Auth-Token: 0c90cc08f56140a3be7217c40731e0fe" \
-X GET -I http://10.5.178.164/5822710/events/2ba0a7f3-74e2-406c-8292-710f9cc4e20d 2> /dev/null | grep '^HTTP')"


OUT_STATUS="$(echo ${OUT_MSG} | awk '{print $2}')"


if [ "${OUT_STATUS}" -ge "200" ] && [ "${OUT_STATUS}" -lt "300" ]; then
  echo "OK - ${OUT_MSG}"
  exit 0
elif [ "${OUT_STATUS}" -ge "300" ] && [ "${OUT_STATUS}" -lt "500" ]; then
  echo "WARNING - ${OUT_MSG}"
  exit 1
elif [ "${OUT_STATUS}" -ge "500" ] && [ "${OUT_STATUS}" -lt "600" ]; then
  echo "CRITICAL - ${OUT_MSG}"
  exit 2
else
  echo "UNKNONE - ${OUT_MSG}"
  exit 3
fi


Last edited by vbe; 10-29-2013 at 03:10 PM..
# 2  
Old 10-29-2013
Perhaps if you told us what you got as error message, we would be more able to help...
We also like to know what shell you are using and knowing the OS does help...
# 3  
Old 10-29-2013
I am using Ubuntu and bash shell. Regarding the error message, when i put the ( args=$1 ) in the script and try to pass the curl value from command line, it doesn't work and come with BLANK value.
# 4  
Old 10-29-2013
perhaps you could try with args="$*"
In your previous post Im quite sure $1 would have returned "curl"...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help from a C++ makefile guru

hello, i'm recompiling some c++ code for OSX and there are some bugs as the configure is not picking up some libs like atlas, pastix, etc, it should be finding either in standard path or with pkgconfig but it's not so i'm rewriting the Makefile. C++ territory is a bit of a stretch with all of... (0 Replies)
Discussion started by: f77hack
0 Replies

2. What is on Your Mind?

Noob and Guru

A long time ago, my computer crashed, at that time, I was using Windows98, but because I was a noob at computers, my friend recommended me apro to fix it for me.   He came, saw the computer, and asked if I had a backup/installation disk for Windows 98. I said no.   He thought about it for a... (1 Reply)
Discussion started by: vistastar
1 Replies

3. Shell Programming and Scripting

New PERL guru's help on strict.pm

I opened strict.pm and found some not understandable stuff, please let me know if you have any Idea on the same. 1) Line 23 => $bits |= (what is $= here how it affect the statement) 2) Line 36 => $^H (what is that I haven't found any statement on this in google) 3) Line 41 =>... (3 Replies)
Discussion started by: jatanig
3 Replies

4. AIX

-- Need help from a AIX guru --

Hi alls I don't see any solution and I need to have feedback from other people... On a test machine (AIX 5.1) I've installed OpenSSH software on it (with openssl, prng, etc...) like is described on IBM AIX Docs. To control the installation I've rebooted the machine and all was ok (CDE was... (15 Replies)
Discussion started by: nymus7
15 Replies

5. Shell Programming and Scripting

UNIX script issues - Plse help guru's

Hi, I have written the following UNIX for HP-UX 11i. The script basically checks for files older then 45mins in 2 repective directories and then sends and email to the administrator about them. Problem with the script is that I can run it from the command line and crontabtab but 80% of the... (2 Replies)
Discussion started by: budrito
2 Replies

6. UNIX for Advanced & Expert Users

TAR prob - Guru's please help

I'm trying to tar 3000 files into a single tar file to be extracted on another server. Command I'm using: find . -name '*cost*' -print| xargs tar -cvf mylist.tar (Note tar is contained on filesystem not tape drive which is what I want) Above command works fine and displays all 3000+ file... (3 Replies)
Discussion started by: budrito
3 Replies

7. UNIX for Dummies Questions & Answers

To all the Java guru...

Please forgive me if this is the wrong place for this post. I didn't see a good place to post this topic in. :D I would like to know what's the most popular and reliable Java IDE out there nowadays? A FREE one would be awesome! :D Thanks for your suggestion! Cheers! (10 Replies)
Discussion started by: laila63
10 Replies

8. UNIX for Advanced & Expert Users

what do most Unix guru's use ? :D

I wanted to know what email app most Sun solaris / unix gurus use ? I have become quite NON microsoft in the last few months in my studying solaris.. thanks simon2000 (6 Replies)
Discussion started by: simon2000
6 Replies

9. UNIX for Advanced & Expert Users

sun guru help!

I installed sun recommended cluster patches for solaris 2.5 on my solaris 2.5 server and then issued a shutdown -i6 -y -g0 to reboot the server but server failed to come back up. the server tries to boot up and goes through initialising memory then server freeze. I try to bring the server up... (7 Replies)
Discussion started by: hassan2
7 Replies

10. UNIX for Advanced & Expert Users

Perl Guru help

I am trying to install Perl 5.005 on solaris 2.5, following the perl installation guide in INSTALL file that comes with Perl software However, according to the installation procedure, it instruct me to to excute "make" command after running the Configure which I did but everytime I excute... (3 Replies)
Discussion started by: hassan2
3 Replies
Login or Register to Ask a Question