New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus • Advice and insight from world-class Apple enthusiasts • Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Apps and Games Discussion of applications and games available for Mac OS X.

HELP!crontab script displays output differently than command line


Post Reply New Thread Subscribe

 
Thread Tools
spankincubus

 
Member Since: Feb 04, 2012
Posts: 4
spankincubus is on a distinguished road

spankincubus is offline
hey guys, I was working on setting up a geeklet for my facebook news feeds.

heres what i am doing

1. I am running a script from crontab every five min.
heres the script. all im doing is removing html tags and tabs from the output of curl.


localhost:geeklets root# cat extrct_fb.sh
#!/bin/ksh

GEEKHOME=/Users/spankincubus/Documents/geeklets
FBLOG=${GEEKHOME}/sajal.txt

curl --silent "http://www.gencolee.com/fb/newsfeedrss.php?u=540891642&s=9f8513cc5b1c6472419e 24.0-540891642"|awk '/pubDate/,/\/description/'|sed 's/^I//g'|sed 's/<[^>]*>//g'|sed 's/\]\]>//g' |sed '/http/d;s/&nbsp;//g'|sed 's/^[^>]*0800$//g'|tr -d " "|fold|cat -s > ${FBLOG}

if [[ $? -eq 0 ]]; then
echo "FB logs written!"
else
exit 1
fi

The output of this script has no spaces between words:
localhost:geeklets root# cat sajal.txt

1RajeshKumar
AgneepathEffect♥


Beta:Mandwa

AlexisMcDaniel
Howaboutbeforewegetwastedtonight,wegetwastedtonigh t?Pregame.

AshwathGowdaDanihalli
PartyingWithMadhu,Harish,pavaninMalleswaram,Banglo re

Mashable
WhichChromepluginswouldyourecommend?

Domino'sPizza
Here’sasecrettoawinningpartyonSunday:placeaDomino’ spre-orderTODAY!



BUT

when i run the curl command from the command line the output(in italics) is flawless (spaces betn words are intact):


localhost:geeklets root# curl --silent "http://www.gencolee.com/fb/newsfeedrss.php?u=540891642&s=9f8513cc5b1c64761241 9e24.0-540891642"|awk '/pubDate/,/\/description/'|sed 's/ //g'|sed 's/<[^>]*>//g'|sed 's/\]\]>//g' |sed '/http/d;s/&nbsp;//g'|sed 's/^[^>]*0800$//g'|tr -d " "|fold|cat -s

1Ashwath Gowda Danihalli
Partying With Madhu , Harish , pavan in Malleswaram,Banglore

Mashable
Which Chrome plugins would you recommend?

Domino's Pizza
Here’s a secret to a winning party on Sunday: place a Domino’s pre-order TODAY!

Best Buy
Take the hassle out of moving your data from your old PC to that shiny new lapto
p.

Mashable
Will you be watching the streaming version of Super Bowl XLVI online?

Sierra Mist
Superbowl party tomorrow? Try out these festive cocktails for a perfect way to w
ash down those game day snacks!

Best Buy
Thank You to Dreams Come True for choosing Best Buy to fulfill Zowanda's wish fo
r electronics!


How can i get the same output from cronning script !
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,813
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
Hmmm, I can't speak to this issue directly (I am neither a cron or sed expert) but I do know that GeekTool has a refresh function. With that, you can have GT refresh the script at a set interval. Maybe you could try that instead of using cron.

I also believe cron has been deprecated in OS X with launchd replacing it. It might be worth looking into that as well.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,638
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
tr -d " " <--- delete character "space"

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks
spankincubus

 
Member Since: Feb 04, 2012
Posts: 4
spankincubus is on a distinguished road

spankincubus is offline
thanks guys.. im stupid.. it was indeed the tr and sed.. i copied and pasted the code. and the ^I(tabs) got transformed to single spaces.

Silly of me. Sorry to waste you guys time..

its working perfectly now.

However i was thinking of refining it some more. i was thinking of making the output of the txt scrollable ie. print lines 0-10, then 11-21 ,.. and so on .. until end of file is reached.
the code is working on command line (see below) but when i call the script in the geektool, it doesnt show anything. any recommendations?

CODE

localhost:geeklets root# cat scroll.sh
#!/bin/ksh

typeset -i start=1
end=`wc -l test.txt|awk -F" " '{print $1}'`
typeset -i end1=$start+10
echo $start $end $end1

while [[ $start -lt $end ]]; do
clear
str="'${start},${end1}p' test.txt"
echo "sed -n $str"|/bin/ksh
start=${start}+1
end1=${end1}+1
sleep 1
done
QUOTE Thanks

Post Reply New Thread Subscribe


« Just purchased iMac, need advice... | iTunes Always Asks For Account Info »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Mapping AFP with Applescript for student macs DrunkMunki OS X - Operating System 3 11-04-2011 02:23 AM
Script for Zoom in MS Office Word 2008 or 2011 Lbatson21 OS X - Apps and Games 1 10-31-2011 10:39 PM
Script to duplicate Apple Lossless iTunes library as MP3 files nick_harambee OS X - Operating System 10 10-02-2010 08:53 AM
Apple confirms LED displays in Macs during 2007 kaidomac Apple Rumors and Reports 17 05-03-2007 11:24 PM

All times are GMT -4. The time now is 08:12 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?