Include lua scripts into executable - windows

Hi this question seems to be answered but answers don't resolve my problem.
I try to include lua script into executable by copying it into exe
copy -b a.exe+test.lua output.exe
but when i launch output.exe luaL_dofile() cannot find lua script.
I dont want to use any third party apps to achieve this.
Copying files seems to work because Love2D projects works and I copy files in the same way but i treats them as zip archive (for sake of file hierarchy).

You can append a Lua script to your .exe but you'll need some way to load it into your program. The main problem is how to find the Lua script at the end of the .exe. srlua appends a small signature that contains the size of the Lua script so that the program can read the script at the right offset in the .exe file. Fortunately, the Lua API provides a function to load scripts from arbitrary sources. The convenience function luaL_dofile uses that function. You can use the same technique in your own program.

Related

Creating a mac app which calls a shell script, but developing in ubuntu

I have a shell script, and a tarball. The shell script unpacks the tarball, and makes use of the files inside of for performing a task. I need to make this accessible on mac laptops, but in such a way that there is either a .app or .dmg file that when clicked, ultimately calls that shell script. I found several utilities, that can do this (create such an .app file), such as Platypus, or Appify. However, these require Mac to build the file. The thing is, I must package the .app/.dmg file, in an Ubuntu environment.
Is there any good software for creating a dmg or app file which call a shell script when clicked, but such that the software which can be run in Ubuntu (just for the purpose of creating the file)?
This is not an exact answer to your question but an workaround that might be acceptable if you can't find a better solution.
First, a zip file will automatically extract its content if you double click it in OS X so
tar -cvzf your_filename.zip ...
would create a file that can be easily extracted.
Secondly, if you create a shell script that has the extension .command, but otherwise is like any shell script, it can be run from OS X by double clicking on it (by opening a terminal and executing it there), it would mean an extra manual step for the user but like I said, this is a workaround :)
If you create a .command file, remember to make it executable.

Building a binary executable for a MacOS app, on Linux

I have at the core a very simple program. A shell script that can run on either mac or ubuntu. I have the requirement to distribute it on both platforms (in the mac case, must be a .app), however, I must build it exclusively on Ubuntu.
I was looking in to what is a mac '.app', and it seems like it's just a unique directory structure with executable, metadata, etc. For example, here are Apple's docs on the matter which explains it.
https://developer.apple.com/library/content/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW1
It seems like the metadata, etc. can all be put together, however in the Contents/MacOS folder, this is where the executable (the app's entrypoint) goes. This is the part I am confused on. For example, is there a way to make my shell script as an 'executable'? Or does this need to be a proper binary file (like you would get by compiling a C program?). If it is the latter, is there a way to do this on a Linux machine? (Noting that, this shell script, or C script I could make it in to, is so simple - essentially a single if/else statement which calls another utility.)
You need to have two things:
Put your executable into the Contents/MacOS directory, and make sure it is world-executable (just call chmod 755 on it). I think a shell script should work here, as long as it's got the correct "shebang" in front. For an actual binary, you'd need to find a way to compile a Mach-O binary on Linux.
Next, you need to make an Info.plist file in the Contents directory. Just dig out any Apple plist file as a template, and put these keys in it:
a. CFBundleExecutable—this should be the filename of your executable in Contents/MacOS
b. CFBundleIdentifier—this should be a unique bundle ID for your application, in reverse-DNS notation, i.e. com.yourwebsitename.yourappname
If you have these components in your .app bundle, it should launch when you double-click on it.

Converting a .exe to .pl in Perl?

I'm trying to get a Perl script (.pl) out of an executable (.exe) file. The .exe file was originally coded in Perl but the .pl file was not kept. Is there a quick way to do this? I'm using Strawberry Perl for windows.
Thanks
Rename .exe to .zip and check if files can be extracted
From the PAR FAQ:
How do I extract my script out of packed executable?
In other words, "I did a `pp foo.pl' and I lost foo.pl, how do I get it back?".
The answer is to just use unzip/winzip/winrar/whatever to decompress the executable, treating it like a normal Zip file. You may need to rename the executable into a .zip extension first.
pp relies on PAR to create the executable. PAR relies on Archive::Zip, so at some level the file contains zipped copies of the perl scripts used to create the executable.
Typically, these programs attach a loader to the front of a zip archive which unzips the files to a temporary directory and invokes the script indicated as the program's entry point.
I'd try two things:
root around in all the typical Temp directories (\Users\Username\AppData\Local\Temp for instance) for a directory containing your script and it's prerequsites.
try to uncompress the exe as a zip, possibly removing the loader from the start of he program first, using a byte editor.

How to compile tcl/shell code (Hide original source code)

Please help with the step by step instructions on "How to compile tcl/ shell code"
(Need to hide original source code)
Please come out with answers considering the following queries
Tools need to accomplish that (Please suggest the best/simple one)
How to compile
How to run the compiled output file
Thanks
Activestate offers a product, the "Tcl Dev Kit" (TDK), which can be used to produce byte-compiled blobs and to otherwise prepare "compiled" applications written in Tcl (also known as "starpacks").
If you are running Linux you can use Freewrap to compile tcl. If your distribution doesn't have it in it's repository download it from http://sourceforge.net/projects/freewrap/ and just pass the name of your tcl script as the argument like this:
freewrap <name>.tcl
This should generate the file <name>, which you can run as any executable. See http://wiki.tcl.tk/855 for other options.
To compile shell scripts use shc. The tool can be downloaded from http://linux.softpedia.com/get/System/Shells/shc-18503.shtml and you compile your shell script with the command
shc -f <name>
This should output two files <name>.x and <name>.x.c. The former is the executable you want and the other is a C code file compiled from your original script that is used to generate the executable.
After almost a decade.
To compile .tcl script, you need TclKit and sdx. You can download them from TclKits: Downloads and Google Code Archive | Downloads. (I used one for RHEL5 x86_64 on Ubuntu.)
After making TclKit executable by
$ chmod +x tclkit-8.*.*-*-*
, the command
$ tclkit-8.*.*-*-* sdx-*.kit qwrap *.tcl
will compile a script file and generate *.kit file. To run it:
$ tclkit-8.*.*-*-* *.kit

Compiling a bash script into a windows executable

I have a script which was origionally made for Linux, but adapted to run with Cygwin in windows, and if you already have the executables (sh, cp, mv, etc.) then you can run it without Cygwin. The only problem is that the script also uses a few hundred (yes hundreds) of other executables. Is there any way I can compile this script into a regular executable and pack these other supporting files in as resources?
The script is ~1600 lines long which is probably too long to confortably re-implement by hand in C++. I am looking to compile the script into something which windows can execute without having to make edits to the path to include a bunch of third party executables. A way to contain all this.
I doubt that the solution you have in mind is feasible.
Instead, I'd modify the script so that the first thing it does is figure out where all those hundreds of executables are. Then either set $PATH appropriately, or invoke each one by its full pathname.
Or you can have an installer that installs the executables in a specified or user-chosen location, then re-generates the script (from an input file) so it knows where the executables are. Ship with the-script.in, then have the installer perform textual substitutions to generate the-script from the-script.in.
I point out:
RPM and SHC
as a possible solution for your problem. Maybe this tools helps you to do the job.
Using SHC to Cygwin is possible to compile bash to exe
Ok. Realy old, but I was looking for it and decide to do my self and make it public.
http://goo.gl/M1NSY
Use ports of the required utils and use some application virtualization tool to package it all up. Cameyo is a free one. Forget Cygwin, that thing is huuuge :)

Resources