Sponsored Content
Top Forums Shell Programming and Scripting Script runs in command-line fine but times out in CRON? Post 302815353 by phpchick on Friday 31st of May 2013 02:40:03 PM
Old 05-31-2013
Sorry, here it is, relatively simple.
Is the bashshebang comment relevant even though the script successfully starts? - At the moment I have no bashshebang in my script but, didn't think this was an issue since it still runs.



Code:
../stocks/aaa-stockuniverse.txt

stock="soda"

eval $(curl -s "http://www.web.com/ig/api?stock=$stock"|sed 's/</\n</g' |sed '/data=/!d; s/ data=/=/g; s/\/>/; /g; s/</GF_/g' |tee ~/stocks/$stock.txt)




while read line
do
    array+=("$line")
done < "/home5/username/stocks/aaa-stockuniverse.txt"

for ((i=0; i < ${#array[*]}; i++))
do
	eval $(curl -s "http://www.web.com/ig/api?stock=${array[i]}"|sed 's/</\n</g' |sed '/data=/!d; s/ data=/=/g; s/\/>/; /g; s/</GF_/g' |tee /home5/username/public_html/dailyquotes/${array[i]}.txt)
	echo "${array[i]},$(date +%Y-%m-%d),$GF_open,$GF_high,$GF_low,$GF_last,$GF_volume"
	sleep $[ ( $RANDOM % 10 )  + 1 ]s
done

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script runs fine on UNIX Server...Not through MSK Tool kit on Windows Server

I have a .sh script which was running fine on all the UNIX Servers (AIX, SunSolaris). The script requires two mandatory parameters and many optional parameters. Now at a different client place who are on a Windows Server, when I try to execute the script through MKS Toolkit, there are couple of... (5 Replies)
Discussion started by: madhunk
5 Replies

2. Shell Programming and Scripting

Cron job fails, but works fine from command line

I have a very basic script that essentially sends a log file, via FTP, to a backup server. My cron entry to run this every night is: 55 23 * * * /usr/bin/archive_logs The script runs perfectly when executed manually, and actually worked via cron for about three weeks. However, it mysteriously... (3 Replies)
Discussion started by: cdunavent
3 Replies

3. Shell Programming and Scripting

Script runs fine, but not in a cron

Okay, I have the following script that runs fine from a command line as well as an executable .sh file. It just moves any file/folder with movie* in the name to a folder called _Movies. The issue I'm running into is when it's call from a cron. find /mnt/HD_a2/BT/complete -iname "movie.*" -exec... (4 Replies)
Discussion started by: sammyk
4 Replies

4. Shell Programming and Scripting

Script Runs fine but not giving any output

Hi, My script is running with no erros but not giving any output can anyonehelp. #!/bin/ksh . /home/application/bin/application.env OUTFILE=Result.txt PROD_PASSWORD=`${GET_PWD} -f ${PWD_FILE_PATH} -s ${PROD_SERVER} -u ${PROD_USER}` echo "1)To get the book last loaded details " read... (7 Replies)
Discussion started by: jagadish_gaddam
7 Replies

5. Shell Programming and Scripting

awk command in script gives error while same awk command at prompt runs fine: Why?

Hello all, Here is what my bash script does: sums number columns, saves the tot in new column, outputs if tot >= threshold val: > cat getnon0file.sh #!/bin/bash this="getnon0file.sh" USAGE=$this" InFile="xyz.38" Min="0.05" # awk '{sum=0; for(n=2; n<=NF; n++){sum+=$n};... (4 Replies)
Discussion started by: catalys
4 Replies

6. Shell Programming and Scripting

Shell script runs fine in Solaris, in Linux hangs at wait command

HI, I have a strange problem. A shell script that runs fine on solaris. when i ported to linux, it started hanging. here is the core of the script CFG_FILE=tab25.cfg sort -t "!" -k 2 ${CFG_FILE} | egrep -v "^#|^$" | while IFS="!" read a b c do #echo "jobs output" #jobs #echo "jobs... (13 Replies)
Discussion started by: aksaravanan
13 Replies

7. Shell Programming and Scripting

CRON shell script only runs correctly on command line

Hi, I'm new to these forums, and I'm hoping that someone can solve this problem... To make things short: I have DD-wrt set up on a router. I'm trying to run a script in CRON that fetches the daily password from my database using SSH. CRON is set like so(in web interface): * * * *... (4 Replies)
Discussion started by: louieaw
4 Replies

8. Shell Programming and Scripting

Script runs fine manually but not in crontab

Hello Guys, I have scratched my head alot on this but couldn't find clue what's wrong. Can you please help me with this? My problem is as following. 1) When I manually execute following script it runs successfully with below output. bash-3.00# more smssend #!/bin/bash echo -e "<Request... (16 Replies)
Discussion started by: umarsatti
16 Replies

9. Shell Programming and Scripting

Part of the Shell script is not running via crontab, runs fine manually

Hello Team, As a part of my job we have made a script to automate a service to restart frequently. Script having two functions when executing it's should find the existing service and kill it, then start the same service . Verified the script it's working fine when executing... (18 Replies)
Discussion started by: gowthamakanthan
18 Replies

10. AIX

Script runs in shell but not cron

We run some menu driven software that has the ability to batch menu paths and generate reports quickly. Normally you run a batch like: $ BATCH BATCHNAME The batch program then prompts you for the date you want the report run for. I got some help from some folks on IRC to do the following: BATCH... (2 Replies)
Discussion started by: herot
2 Replies
YahooQuote(3pm) 					User Contributed Perl Documentation					   YahooQuote(3pm)

NAME
Finance::YahooQuote - Get stock quotes from Yahoo! Finance SYNOPSIS
use Finance::YahooQuote; # setting TIMEOUT and PROXY is optional $Finance::YahooQuote::TIMEOUT = 60; $Finance::YahooQuote::PROXY = "http://some.where.net:8080"; @quote = getonequote $symbol; # Get a quote for a single symbol @quotes = getquote @symbols; # Get quotes for a bunch of symbols useExtendedQueryFormat(); # switch to extended query format useRealtimeQueryFormat(); # switch to real-time query format @quotes = getquote @symbols; # Get quotes for a bunch of symbols @quotes = getcustomquote(["DELL","IBM"], # using custom format ["Name","Book Value"]); # note array refs DESCRIPTION
This module gets stock quotes from Yahoo! Finance. The getonequote function will return a quote for a single stock symbol, while the getquote function will return a quote for each of the stock symbols passed to it. getcustomquote allows to specify a format other than the default to take advantage of the extended range of available information. The download operation is efficient: only one request is made even if several symbols are requested at once. The return value of getonequote is an array, with the following elements: 0 Symbol 1 Company Name 2 Last Price 3 Last Trade Date 4 Last Trade Time 5 Change 6 Percent Change 7 Volume 8 Average Daily Vol 9 Bid 10 Ask 11 Previous Close 12 Today's Open 13 Day's Range 14 52-Week Range 15 Earnings per Share 16 P/E Ratio 17 Dividend Pay Date 18 Dividend per Share 19 Dividend Yield 20 Market Capitalization 21 Stock Exchange If the extended format has been selected, the following fields are also retrieved: 22 Short ratio 23 1yr Target Price 24 EPS Est. Current Yr 25 EPS Est. Next Year 26 EPS Est. Next Quarter 27 Price/EPS Est. Current Yr 28 Price/EPS Est. Next Yr 29 PEG Ratio 30 Book Value 31 Price/Book 32 Price/Sales 33 EBITDA 34 50-day Moving Avg 35 200-day Moving Avg If the real-time format has been selected, the following fields are also retrieved: 36 Ask (real-time) 37 Bid (real-time) 38 Change in Percent (real-time) 39 Last trade with time (real-time) 40 Change (real-time) 41 Day range (real-time) 42 Market-cap (real-time) The getquote function returns an array of pointers to arrays with the above structure. The getonequote function returns just one quote, rather than an array. It returns a simple array of values for the given symbol. The setQueryString permits to supply a new query string that will be used for subsequent data requests. The useExtendedQueryFormat and useRealtimeQueryFormat are simpler interfaces which append symbols to the default quote string, as detailed above. The getcustomquote returns an array of quotes corresponding to values for the symbols supplied in the first array reference, and the custom fields supplied in the second array reference. Here the custom fields correspond to the 'named' fields of the list below. Beyond stock quotes, Finance::YahooQuote can also obtain quotes for currencies (from the Philadephia exchange -- however Yahoo! appears to have stopped to support the currency symbols in a reliable manner), US mutual funds, options on US stocks, several precious metals and quite possibly more; see the Yahoo! Finance website for full information. Finance::YahooQuote can be used for stocks from the USA, Canada, various European exchanges, various Asian exchanges (Singapore, Taiwan, HongKong, Kuala Lumpur, ...) Australia and New Zealand. It should work for other markets supported by Yahoo. You may optionally override the default LWP timeout of 180 seconds by setting $Finance::YahooQuote::TIMEOUT to your preferred value. You may also provide a proxy (for the required http connection) by using the variable $Finance::YahooQuote::PROXY. Furthermore, authentication-based proxies can be used by setting the proxy user and password via the variables $Finance::YahooQuote::PROXYUSER and $Finance::YahooQuote::PROXYPASSWD. Two example scripts are provided to help with the mapping a stock symbols as well as with Yahoo! Finance server codes. The regression tests scripts in the t/ subdirectory of the source distribution also contain simple examples. The available custom fields The following list contains all the available data fields at Yahoo! along with the corresponding format string entry: Symbol s Name n Last Trade (With Time) l Last Trade (Price Only) l1 Last Trade Date d1 Last Trade Time t1 Last Trade Size k3 Change and Percent Change c Change c1 Change in Percent p2 Ticker Trend t7 Volume v Average Daily Volume a2 More Info i Trade Links t6 Bid b Bid Size b6 Ask a Ask Size a5 Previous Close p Open o Day's Range m 52-week Range w Change From 52-wk Low j5 Pct Chg From 52-wk Low j6 Change From 52-wk High k4 Pct Chg From 52-wk High k5 Earnings/Share e P/E Ratio r Short Ratio s7 Dividend Pay Date r1 Ex-Dividend Date q Dividend/Share d Dividend Yield y Float Shares f6 Market Capitalization j1 1yr Target Price t8 EPS Est. Current Yr e7 EPS Est. Next Year e8 EPS Est. Next Quarter e9 Price/EPS Est. Current Yr r6 Price/EPS Est. Next Yr r7 PEG Ratio r5 Book Value b4 Price/Book p6 Price/Sales p5 EBITDA j4 50-day Moving Avg m3 Change From 50-day Moving Avg m7 Pct Chg From 50-day Moving Avg m8 200-day Moving Avg m4 Change From 200-day Moving Avg m5 Pct Chg From 200-day Moving Avg m6 Shares Owned s1 Price Paid p1 Commission c3 Holdings Value v1 Day's Value Change w1, Holdings Gain Percent g1 Holdings Gain g4 Trade Date d2 Annualized Gain g3 High Limit l2 Low Limit l3 Notes n4 Last Trade (Real-time) with Time k1 Bid (Real-time) b3 Ask (Real-time) b2 Change Percent (Real-time) k2 Change (Real-time) c6 Holdings Value (Real-time) v7 Day's Value Change (Real-time) w4 Holdings Gain Pct (Real-time) g5 Holdings Gain (Real-time) g6 Day's Range (Real-time) m2 Market Cap (Real-time) j3 P/E (Real-time) r2 After Hours Change (Real-time) c8 Order Book (Real-time) i5 Stock Exchange x FAQs How can one figure out the format string? Provided a My Yahoo! (http://my.yahoo.com) account, go to the following URL: http://edit.my.yahoo.com/config/edit_pfview?.vk=v1 Viewing the source of this page, you will come across the section that defines the menus that let you select which elements go into a particular view. The <option> values are the strings that pick up the information described in the menu item. For example, Symbol refers to the string "s" and name refers to the string "l". Using "sl" as the format string, we would get the symbol followed by the name of the security. The example script examine_server.sh shows this in some more detail and downloads example .csv files using GNU wget. What about different stock symbols for the same corporation? This can be issue. For the first few years, Yahoo! Finance's servers appeared to be cover their respective local markets. E.g., the UK- based servers provided quotes for Europe, the Australian one for the Australia and New Zealand and so on. Hence, one needed to branch and bound code and map symbols to their region's servers. It now appears that this is no longer required, which is good news as it simplifies coding. However, some old symbols are no longer supported -- yet other, and supported, codes exist for the same company. For example, German stocks used to quoted in terms or their cusip-like 'WKN'. The main server does not support these, but does support newer, acronym-based symbols. The example script examine_server.sh helps in finding the mapping as e.g. from 555750.F to DTEGN.F for Deutsche Telekom. COPYRIGHT
Copyright 1998 - 2002 Dj Padzensky Copyright 2002 - 2007 Dirk Eddelbuettel This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The information that you obtain with this library may be copyrighted by Yahoo! Inc., and is governed by their usage license. See http://www.yahoo.com/docs/info/gen_disclaimer.html for more information. AUTHOR
Dj Padzensky ("djpadz@padz.net"), PadzNet, Inc., wrote the original version. Dirk Eddelbuettel ("edd@debian.org") provided several extensions based on DJ's original work and is the current maintainer. SEE ALSO
The Finance::YahooQuote home pages are found at http://www.padz.net/~djpadz/YahooQuote/ and http://dirk.eddelbuettel.com/code/yahooquote.html. The smtm (Show Me The Money) program uses Finance::YahooQuote for a customisable stock/portfolio ticker and chart display, see http://dirk.eddelbuettel.com/code/smtm.html for more. The beancounter program uses it to store quotes in a SQL database, see http://dirk.eddelbuettel.com/code/beancounter.html. perl v5.10.1 2010-03-27 YahooQuote(3pm)
All times are GMT -4. The time now is 12:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy