Is it possible to create a directory in lua ? If so, how ?
You may find the LuaFileSystem library useful. It has a mkdir function.
require "lfs"
lfs.mkdir("/path/to/dir")
There's a "system" call (or something like that, this is from memory) which you should be able to use to run an arbitrary program, which could include the mkdir command.
EDIT: I found my Programming in Lua book. On page 203, it mentions how you could use an
os.execute("mkdir " .. dirname)
to "fake" a directory creation command.
EDIT 2: Take note of Jonas Thiem's warning that this command can be abused if the directory name comes from an untrusted source!
You may also want to look at Lua/APR, the Apache Portable Runtime binding for Lua. The docs can be found at here
One of the reasons I use Lua is that I can write code that runs across multiple OSes. I was using LFS for some time, but have found that using Lua/APR provides a more platform-neutral library. And there are lots of other useful routines in the APR.
You can use the paths package instead. Then you can simply do:
require 'paths'
paths.mkdir('your/dir')
Related
Basically, I'm curious if something like SBT including the version number in a program is possible for Scala.js. The proposed solution doesn't work in scala.js, apparently due the the absence of the getPackage method:
[error] Referring to non-existent method java.lang.Class.getPackage()java.lang.Package
Use sbt-buildinfo for that. The Usage section of the readme contains everything you need.
I would like my Hack code to be broken down to Abstract Syntax Tree. Please advise me on available tools/libraries/github repositories which will help me to parse Hack code into AST.
I have found "h2tp" (hack to php transpiler written by Facebook), however it doesn't parse the code into AST. I also tried this project which does what I want however it is not recognising many of the operators and requires a significant rework, which will quite a lot of time to do.
hhast (HHAST: Low-Level AST Library) lets you do that, you may invoke hh_parse like this : hh_parse --full-fidelity-json $file | jq
taken from (https://github.com/hhvm/hhast/blob/master/docs/ast-lib.md)
The HHVM itself provides a lot of tools to dump the structure of a PHP file. However, the AST dump was removed: https://github.com/facebook/hhvm/issues/1268
What you can do is dump the HHVM assembly language: http://hhvm.com/blog/6323/the-journey-of-a-thousand-bytecodes
HHVM also has a PHP transpiler which may help:https://docs.hhvm.com/hack/tools/transpiler
You could also try to port this extension over to the HHVM: https://github.com/nikic/php-ast
in my project, I want to refer to an other xcconfig file, located in InDesign SDK. As this SDK may be installed at different locations, depending upon the machine, I prefer to declare an environment variable for locating it.
Nest step is obviously to use variable (aptly named ID_CS5_SDK_DIR) in my xcconfig include directive.
Unfortunatly, when I try the simple
// InDesign sdk project build settings (based on common build settings)
#include "$(ID_CS5_SDK_ROOT)/build/mac/prj/_shared_build_settings/common.xcconfig"
XCode throws me a
[WARN]AutocatPlugin.xcconfig line 7: Unable to find included file "$(ID_CS5_SDK_ROOT)/build/mac/prj/_shared_build_settings/common.xcconfig"
How can I make it work ?
I've been trying to do this too and also came to the conclusion that it is not possible.
I once tried to achieve that and came to the conclusion that you can't. I would be happy if someone proves us it's possible though then delete my answer
It seems like .xcconfig files can only DEFINE and set value to environment variables (which prevail only throughout the build session) but not USE or evaluate environment variables.
Maybe it is because .xcconfig files serve as a base layer of build-settings, and are not parsed.
Unfortunately this is not possible, but instead of making one include the other, you can use two different xcconfig files per target. Just select one for the Project and one for the Target.
If you put the environment variable in /etc/config/launchd.conf and then reboot it will be accessible to the .xcconfig file.
Short Instructions for experienced users:
Edit the read-only file /etc/launchd.conf and add 'setenv VARIABLENAME /FOLDER/PATH' to the file, then reboot.
Steps For Inexperienced Users
Open Application/Utilities/Terminal, and entersudo nano /etc/launchd.conf
Create the Environment Variable by adding a line like setenv VARIABLENAME FOLDER/PATH and then pressing ENTER.
Save the file using Ctrl-O, Ctrl-M, (Possibly Ctrl-Y to overwrite), then Ctrl-X to exit the editor.
(Optional) type cat /etc/launchd.conf to see that your changes are present
Restart your computer. (Logoff doesn't work)
You can now access the variable in your .xcconfig file as$(VARIABLENAME)
Notes:
This creates a GLOBAL environment variable, accessible to all users. It probably doesn't make sense to set this to something in your home directory (e.g ~/MyFolder). If you do this, however, you need to use the full pathname, such as /Users/MyUserName/MyFolder).
References:
Stack Overflow - Setting Environment Variables in OSX
Stack Overflow - Are there any differences between /etc and /private /etc
I want to know the way to add new asterisk applications and modules.For example I don't have the SetGlobalVar application in my asterisk machine.I want to add that.Is there any way.
Thanks in advance .
As for SetGlobalVar you can use Set with g option as described in Asterisk wiki. Instead of writing such application write simple program that changes dialplan.
If you want to add some other thing to Asterisk there is simpler option than adding application: use AGI with your favorite programming language.
You can also use the GLOBAL() function. For example:
exten => 1234,1,Set(GLOBAL(MY_GLOBAL_VAR)=value)
I might be completely off-base here, but, I believe what the OP is asking for is how to actually load this module.. Assuming your asterisk distribution shipped with func_global, just do "module load func_global.so". If you want it to load on asterisk startup, add it to your modules.conf.
If your distribution doesn't package asterisk with that module, then you're going to have to either rebuild the package and include it, or build just that module from vanilla asterisk sources, then copy it over to your lib/modules directory.
Depending on your Asterisk version, that application may actually not even exist any more. I believe it was removed with Asterisk 1.8 and following.
When using HP-UX I can use the chatr utility to report on various internal attributes of a shared library. It will also allow me to modify the internal attributes of shared libraries that I have built.
The chatr utility can report, and in some cases modify, such things as:
the run-time binding behaviour,
the embedded library path list created at build time,
whether the library is subject to run-time path lookup,
internal names,
etc., etc.
Is such a utility available for Solaris?
Edit: Freaky! Thanks to mark4o's answer below I revisited the elfdump output for a typical system .so (libm.so.2 on Sol 10). However, and here's the freaky part, I mistyped the command to enter:
elfdump libm.so.2 | moe
In an amazing stroke of serendipity, this gave me back the usage message for a utility called moe whose man page description section says:
The moe utility manifests the optimal expansion of a path-name containing reserved runtime linker tokens. These tokens can be used to define dependencies, filtees and runpaths within dynamic objects. The expansion of these tokens at runtime, provides a flexible mechanism for selecting objects and search paths that perform best on this machine.
This will help me resolve why a libm.so.2 shlib is not compatible on both of two different machines leaving my incomplete executable unable to start on one server.
For displaying the information, see the Solaris elfdump and pvs utilities. For debugging binding issues, lari and moe may also be helpful. However, these utilities do not have the ability to modify the library.
Starting with Solaris 11 (and some of the OpenSolaris & Solaris Express releases leading up to it, but not Solaris 10 or older), there is now an elfedit tool for modifying runtime paths and similar attributes.