ping cronjob problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ping cronjob problem
# 1  
Old 08-06-2003
ping cronjob problem

Hi all,

I'm trying to write a shell script that will ping a site and and write the date and 1 or 0 (for success or no success) to a file.

it looks roughly like this:

#/bin/sh

set mydate = `date`
set myvar = `ping -c 1 hostname | grep -c "100%"`
if ($myvar == 1) then
echo $mydate" 0" >> banneruptime.txt
else
echo $mydate" 1" >> banneruptime.txt
endif

It works when I call it from the commandline, but not when i call it from a cronjob. On my MacOS X machine ping resides in /sbin, so I added that to the cronpath. But I get a "syntax error: unexpected end of file" error.

Any ideas? Thanks.
# 2  
Old 08-06-2003
Call me stupid but I thought I had tried everything before posting. I got it to work, I was using /bin/csh in the script but /bin/sh in the cronjob. Added "SHELL=/bin/csh" and now it works.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ping - cut and sed - problem

How can I get the following result of the "ping" command? Example: root@OpenWrt:~# ping google.com -c1 | sed -n 1p PING google.com (216.58.210.14): 56 data bytes How can I get the data only in the range of ()? The result of what I want to get it: 216.58.210.14 Please use code... (4 Replies)
Discussion started by: andrewxxx
4 Replies

2. UNIX for Advanced & Expert Users

UI accessiblity problem when using cronjob for server restart

Hi, I have a couch Db server running. I have written a script which will check and kill the multiple instances of the same and then start again a new one. Now when i start the db server manually, the UI of the DB is accessible via browser. But when i do the same using cronjob, the UI of... (0 Replies)
Discussion started by: sarath@123
0 Replies

3. Solaris

Ping problem???

Hi friends, I am running Solaris 10, which is connected to a DSL router running DHCP. During the installation I chose not to use DHCP and assigned a permanent IP address to solaris machine. I also did not choose any name service as well. The rest of the details are as under. Solaris Machine IP... (4 Replies)
Discussion started by: gabam
4 Replies

4. AIX

Problem with 'ping' command

Hi All, I'm testing ping command on two servers. A,B,C,D are servers From A-->B: ping -c 3 -p ff -s30720 <B IP-Addres> This works fine. From C-->D: ping -c 3 -p ff -s30720 <D IP-Addres> This is NOT working and 100% packe loss :( But if I use 8700 instead of 30720 for packet size... (6 Replies)
Discussion started by: saraperu
6 Replies

5. Solaris

Ping Problem

Can someone tell me how I can get the following bolded output without having to issue the control C key when a ping is running? ping -s cca-wl6 PING cca-wl6: 56 data bytes 64 bytes from cca-wl6: icmp_seq=0. time=0.796 ms 64 bytes from cca-wl6: icmp_seq=1. time=0.581 ms 64 bytes from... (5 Replies)
Discussion started by: SkySmart
5 Replies

6. IP Networking

Ping Problem

Comp1=192.168.100.2 Comp2=192.168.100.6 both the comp have win2000 Os. Using Cross cable i have connected back to Back. When i ping From Comp1 to Comp2 its working fine. But When i ping From Comp2 to Comp1 its not working. I know don't know what went wrong please help me out.... (4 Replies)
Discussion started by: ashokmeti
4 Replies

7. Shell Programming and Scripting

help help cronjob problem with script

hi all, have no experience with cronjob at solaris, i have create script like below: #!/bin/sh DAY=`/export/home/oracle/bin/lastdate | nawk '{print $1}'` /export/home/orahome/bin/sqlplus -s abc/abc<<eof set heading off; set linesize 100; set feedback off; spool... (4 Replies)
Discussion started by: bucci
4 Replies

8. UNIX for Dummies Questions & Answers

ping problem

I can ping by ip address but not by host name everything is on the same subnet check all of the normal files I can telnet in to the unix box but can not open a connect to the share dir. unix ver sunSO 5.9 all the other computers ar Windows XP (with firewall turn off) Thanks... (1 Reply)
Discussion started by: vviscomi
1 Replies

9. Shell Programming and Scripting

Problem with cronjob...

Hi All I want to run a script every half an hour everyday, but it looks like it is not working the way it is supposed to. I use the line 0,30 * * * * ksh /...<script> But it only runs every hour at 30 minutes. Am i doing something wrong ? I use AIX 5.1 as my OS. Thanks In... (1 Reply)
Discussion started by: kswaraj
1 Replies

10. Shell Programming and Scripting

Ping problem. system down!!

I wrote a script to test many systems to see if they are up or not. if a system is down, i am notified by email now, most of the time,when systems are down in my enviroment, it is because the user accidentally or purposely (not knowing the consequences) hit the power button. so these problems... (3 Replies)
Discussion started by: TRUEST
3 Replies
Login or Register to Ask a Question