ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a script that processes a daily count up to fifty days and generates a text-to-speach file which it then schedules to run at a specific time. Last year this script worked fine.
Did thy make a change to bash that would cause this code to fail?
That line is not a script.
Can you provide more of the script please?
At the very least, the lines where the variables referenced in that command are set.
It makes sense that the second condition will not be evaluated IF th first condition returns false. That is expected behavior, sine the value of the second condition is not NEEDED if the first one is false.
Also, the LANG and TIMEZONE settings may help.
Does your script do any logging so you can check the values of the variables when execution reaches that point? IF not, you may want to add some logging to make troubleshooting easier.
FYI: While it is not invalid, I would never structure the condition quite that way. I use the number of the month, rather than the name, so textual changes in the way the name string is presented will not break the script. That may, or may not apply, depending upon how you are setting the month in the Jewish calendar into the environment.
Also, in the second condition you compare a string to a number. The shell is smart enough that this will generally work as you would expect, but there are more correct techniques. ( This last is not an issue with the current case, if the second is not being evaluated anyway. I just wanted to mention it. )
It looks like both CURRENTMONTH and CURRENTDAY have a leading newline character, and the string "\nNisan" doesn't match "Nisan". Since you're using the numeric conversion of CURRENTDAY, that leading whitespace character probably doesn't matter, but for the string comparison it does. It is not apparent to me where that newline character came from. It must have something to do with your locale settings.
We would probably need to see the output from hdate to see why awk is returning an additional newline prior to its value, but based on the presented code, I also see no reason for the additional character.
The locale settings would also be worth a check ... but one would think you know if you changed those?
@norobro - Your example will fail for multiple reasons, the first being that (()) only tests numeric values so the first test will throw an error and secondly for the reasons mentioned that the leading
newline will still make the text comparison fail (even if it could work)
From the screenshots on the libhdate webpage (http://libhdate.sourceforge.net/?q=node/3) it looks like the line feed is a feature. They pipe output to column to get rid of it but you can test for an empty field in awk:
Does not look like a locale problem. If hdate does not have any latitude longitude or UTC offset inputs it adds a linefeed regardless of the -q (suppress warnings) or sending stderr to /dev/null
You could either strip the linefeed using any sort of string function or include the missing options.
Quote:
~/$ hdate
hdate: ALERT: time zone not entered, using system local time zone: DST, -X:0 UTC
hdate: ALERT: guessing... will use co-ordinates for
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.