esrcript cron blues - cron

I have an escript file which runs fine from the command line, i.e.:
./escript_file
It is meant to be cron friendly and all paths are explicit but when I run it, it fails to compile saying that there are bad attributes.
The bad attributes in question are macro definitions:
-define(COOKIE, 'somecookie').
The Answer
Thanks to Geoff Ready's suggestion I investigated which version of Erlang was running by printing out init:script_id() which prints out a string like {"OPT APN 181 O1", "R13B"} and, sure enough the command line and cron versions were picking up different versions.
The script had an initial line:
#!/usr/bin/env escript
and the operating system was 'finding' Erlang for me. The different environment variables of cron meant that a different erlang was being picked up (Geoff's first answer, and one I kinda knew but couldn't see how it would affect things).
The solution is then to force the version with a starting line of:
#!/usr/local/lib/erlang/erts-5.7.3/bin/escript
Postscript
There was also a different Ubuntu apt-get install of an earlier version of Erlang (in a different location to the source install) and an errant 64-bit install...
The cron environment just kept falling back to older and more obscure installs, failing all the while :(

Perhaps cron is picking up a different version of erlang in the path. Erlang R12B documentation says that escript ignores preprocessor directives besides include_lib. Erlang R13B documentation says that the preprocessor is run on the file. That would definitely explain the difference in behavior.

If it is working fine from the command line, a likely cause is a difference in environment variables for your interactive shell versus when cron runs the script.

Changing #!/usr/bin/env escript to #!/usr/local/bin/escript at the top of the file will work if the Erlang versions are the same.

Related

Wine + Cygwin garbles argv

I'm trying to compile a program (sbcl to be precise) under Wine + MinGW/Cygwin environment. I've fixed plethora of different quirks, but now I'm stuck on the fact that this environment breaks command line arguments in weird way. The problem is that build shellscript contains the lines
./src/runtime/sbcl --core output/cold-sbcl.core \
--lose-on-corruption $SBCL_MAKE_TARGET_2_OPTIONS --no-sysinit --no-userinit \
--eval '(sb-fasl::!warm-load "src/cold/warm.lisp")' --quit
...but within the running sbcl process the last command line argument appears as (sb-fasl;!warm-load "src/cold/warm.lisp"), which is, of course, syntactically incorrect and the build fails.
I've performed some tests with different versions of wine (I've tried versions 6.0, 6.12 and 6.15) and win32 bash (I've tried a plenty of those, including busybox for windows, currently stuck with the one from old MSYS-20111123.zip from here since it does not exhibit FAST_CWD bug that is currently not fixed). It appears that every time the command line contains both double colon and forward slash, some part of the environment changes double colon to semicolon. I'm not sure where to look for that behaviour to circumvent it - is that shell escaping, or exec syscall behaviour? Could it be that this behaviour is hardcoded into exec function in msvcrt.dll?

Specify Python3 to Atom on Windows 10

In advance, sorry if this is question ought be on SuperUser or another site
The python3 shebang doesn't seem to work on win10. (I cant check right now, but I believe the analogous approach worked on MacOS for me last night). Consider the following
#!/usr/bin/env python3
print("hello world")
Leads to the error 'python' is not recognized as an internal or external command,
operable program or batch file. This makes sense because I only have a python3 distro on my machine (which can only be called like python3). However, Atom seems to be ignoring the shebang altogether. FYI, I'm running the script with the popular "script" atom package.
I've tried the permutation, #!/usr/bin python3, but this doesn't work either.
I've tried permutations
I'm still interested in how shebangs work within the Atom environment, but as far as getting python3 up and running, you dont need a shebang. You can simply change a config file (python.coffee) from within Atom, then relaunch. See Daniel Chamorro's excellent answer here: How to setup Atom's script to run Python 3.x scripts? May the combination with Windows 7 Pro x64 be the issue?

How to debug init file which cause "emacs24.4 --daemon" doesn't return to shell?

Just got emacs24.4 compiled and try to run it in daemon mode.
OS: Ubuntu 14.04
In terminal:
When I run it with "emacs -Q --daemon" everything works fine. But when I run it with "emacs --daemon", it doesn't return to shell (emacs24.3 works fine).
Is there any easy way to debug what's wrong in the init file which works fine for 24.3 but not 24.4?
Recursively bisect your init file, to find out what the culprit code is. You can do this by commenting out 1/2 of it, then 3/4 of it, then 7/8, then 15/16,... IOW, a binary search - it is very quick.
You can use command comment-region to comment or (with C-u) to uncomment the region. (I bind it to C-x C-;.)
Then remember this answer. It applies to any problem introduced by your init file.
Everything in your question that has to do with "Emacs 24.4" and "daemon" and "shell" only becomes relevant (if it is) after you have narrowed things down to find just what code is responsible for introducing the bad behavior.Once you do that, if the solution to what remains is not obvious, then please post another (new) question here that covers the relevant info, whether it be Emacs 24.4, shell, daemon, or whatever.

CYGWIN=nodosfilewarning doesn't help cygwin warning

When I try to use ediff-revision under Emacs 23.2.1 for a CVS-managed file, I receive the following error in the *ediff-errors* frame, instead of commencing directly to the ediff results:
cygwin warning:
MS-DOS style path detected: c:/Users/BILL/AppData/Local/Temp/misc.cpp.~1.10~
Preferred POSIX equivalent is: /cygdrive/c/Users/BILL/AppData/Local/Temp/misc.cpp.~1.10~
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
My problem is that I have already set that CYGWIN environment variable option "nodosfilewarning", so I have no idea why I am receiving this error.
In fact, I can verify this right from an inferior shell under the same Emacs instance:
> set | grep -i nodos
CYGWIN=nodosfilewarning
I am running Cygwin 1.7.9-1 under Windows 7, in case this may be relevant (and I never had this problem before upgrading from Cygwin 1.5 to 1.7).
Any idea how to get rid of this error?
P.S. A subsequent call to ediff-revision succeeds without triggering this warning.
The CYGWIN variable is parsed when the first process in a Cygwin process tree is invoked. Hence, setting it in .bashrc or something like that is too late. A good place to set it is in the global Windows environment, under Control Panel->System->Advanced->Environment Variables.
I added (setenv "CYGWIN" "nodosfilewarning") to setup-cygwin.el. That seems to take care of the problem without, AFAICT, creating other problems. I also filed Emacs bug #14541 for this.
From within emacs, you may also:
M-x setenv
CYGWIN
nodosfilewarning
as an immediate alternative to altering setup-cygwin.el.

Will Perl upgrade break older version on Linux?

I upgrade perl from perl58 to perl588 on Suse Linux.It looks that even though the Config.pm exists for the older version the newer version installation breaks the older version.While the upgrade of Perl on other OSes like HP and AIX does not disturb the older version.
For eg: The perl58 and perl588 versions are present in folder say "/usr/standard_perl" as follows:
/usr/standard_perl/perl58 (directory)
/usr/standard_perl/perl588 (directory)
and have symbolic links pointing to it.
Before and after upgrade the links are as follows:
Before:
perl58_link -> /usr/standard_perl/perl58
After:
perl5_link -> /usr/standard_perl/perl588
perl58_link -> /usr/standard_perl/perl588
perl588_link -> /usr/standard_perl/perl588
Now when i try to run simple "./perl -V" command from /usr/standard_perl/perl58/bin the older version complains of Config.pm not found even though its very well present in its own tree structure.
Is it that in Linux, perl is following a hard coded path for #INC.This kind of behaviour is observed only on Linux.
I am worried for I cannot roll to production for there are scripts that have been running for older version and if this kind of behaviour exists I would need to know if its possible to fix or this is a known behaviour of Linux.
I am not sure could this be because now the older links after upgrade is been pointed to newer version and just linking is not sufficient and need to modify something more on LINUX?
Note:
1.The perl modules are seperately maintained for each version
2.I am not mixing any of the files with previous version.
3. We want all of the old perl scripts running in production servers not to break and use latest version instead for the mainatainence of Perl versions.
3a.Hence a need to tweak the links pointing to latest version instead of their own versions.
Observation:
Only on Linux seeing this behaviour.
One point worth noting is when i twek links of older version to latest version. the #INC automatically is updated for latest version INC and not in LINUX.
Am i missing something here?
I've never seen this problem on Linux. I leave the original perl in its location (/usr/bin/perl), and simply compile my own perl to install to /usr/local/bin (or whatever), and have never seen any breakage of the old version.
You don't say
how you came to have a /usr/standard_perl/perl588 (compiled, given in rpm format or something, pre-compiled tarball, ...)
what options you used when configuring the compilation
You're also very vague with your details - perl58_link, standard_perl, etc. - where is this really? Most of the time it doesn't matter, but sometimes it does.
If you move the link back, do things start to work? If you move the entire 5.8.8 tree somewhere else, do things start to work? Can you recover your base perl from RPM or whatever to try to make it work? IMO, the base perl working is paramount, a secondary perl is always bonus. (I'd take the same opinion of other core unix tools, like shells, awk, sed, or even python or whatever your distro uses for package management. Less so for non-core tools like Java, but if I were running Java apps in production then I'd say the same here, too.)
Leave the system perl executable alone, compile your own, and have your Perl programs run using the one you compiled
All system programs written in Perl should start with:
#! /usr/bin/perl
All non-system Perl programs, user written programs:
This one will use which ever perl executable is found first on $PATH. (same as 'which perl')
#! /usr/bin/env perl
Another option is to specify exactly where the executable you want to use is:
#! /opt/bin/perl
#! /opt/perl/bin/perl
#! /opt/perl/5.10.0/bin/perl
#! /opt/perl-5.10.0/bin/perl
#! /home/$user/perl/bin/perl
#! ~/bin/perl
Or what ever the path to the perl executable is.
Never replace /usr/bin/perl with one you compiled yourself!
I did this once on Ubuntu 7.10, and it broke my system. I could login, and do most everything, but I couldn't change the appearance, for example. I ended up running 'sudo nano $filename' on every Perl program on my computer, and change them so they would run under Perl 5.10, instead of Perl 5.8.
After which I had to install Ubuntu 8.10 from scratch, when it finally came out.
You could also experience incompatibilities if you use cpan or cpanp to install modules, because they could have an incompatible feature change. And for a non-binary compatible perl executable, you have to reinstall all modules that require XSubs.
Thats why all Perl programs that I write I add the header '#!/usr/bin/env perl', and add the path to the Perl executable, to the beginning of the $PATH variable.

Resources