Generating command arguments with a loop in bash -


Is it possible to put a loop inside my code? Want to plot a field for every day of the current month and save a file? One way is difficult, but it is not fun, and due to the number of days of each month is impractical. Want to do something like "every day of the mont ..." or "while the day lt; lastDay ...."

  #! / Bin / bash #Generator Staplegraph for Newward Meded # Sparar File NL YYYY-MM-bar.png # Envanced Tax Rev: 1min # Om Script Course Manual, Sudo # Todo: Logic for Space Managed NL. "$ Simple_bar_generator.sh YYYY-MM" month = $ (date +% m) days = $ (date +% d) monthSTR = $ (date-d "- $ (date +% d) day +1 months" +% B) Year = $ (date +% y) First day = $ (date -d "-0 month - $ (($ (date +% d) -1) Day # + YYYY-MM -DD ​​lastDay = $ (date -d "$ firstDay + 1 month - 1 day '+% Y% m% d) /etc/elmatare.conf imgPath =" / var / www / img # YYYY-MM-DD source / "TempPath =" / tmp / $ years $ months bar.png "/ usr / bin / rrdtool graph $ tempPath \ --start $ firstDay \ --end $ lastDay \ --width 1600 \ --height 400 \ --title 'Förbrukning $ monthStr Högmora 4: 4' \ --vertical-labeled 'kWh' \ --alt-y-grid \ --right axis 1: 0 \ --units-exponent 2 \ --color grid # 00000050 \ - -color M GRID # 00000080 \ while [$ firstDay -le $ lastDay]; Dof: tot = $ powerDBPath: Tot: AVERAGE: start = YYYYMMDD: end = YYYYMMDD \ CDEF: w = tot, 3600, * \ CDEF: energiK = tot, 1000 , / \ VDEF: value_sum = energiK, TOTAL \ CDEF: value_area = w, w, - value_sum, + \ AREA: value_area # AAAAee \ LINE1: value_area1 # 000000 \ GPRINT: value_sum: "$ day for testing purposes:% 0.2lfkWh "\ mv $ tempPath $ imgPath  

Any good luck

  $ ./simple_bar_generator.sh ./simple_bar_generator.sh: line 31: unexpected token Pass syntax error `` tax./simple_bar_generator.sh: line 31: `while [$ first del-la $ last day]; Do ' 

The last loop looks like this: Adding an index to the variable does not accept the reuse of the rrdtool variable.

  args = () day = $ firstDay i = 1 while [[$ day! = $ (Date -d "$ last day + 1 day" +% Y% m% d)]]; Do day = $ (date -d "$ day + 1 days" +% Y% m% d) args + = (def: original $ i = "$ powerDBPath: $ DS: average: start = $ day: end = $ DayStop "CDEF: w $ = i note $ i, 3600," * "CDEF: energiK $ i = tot $ i, 1000, / VDEF: value_sum $ i = energiK $ i, total CDEF: value_area $ i = w $ i , W $ i, -, value_sum $ i, + area: value_area $ i # aaaai line1: value_area $ i # 000000 GPRINT: value_sum $ i: "Forwarding (for testing) $ day% 0.2lfkWh \ n") day = $ (Date-D "$ day + 1 day" +% Y% m% d) I = $ [$ i + 1]  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -