C
C
cursed2012-02-20 18:21:57
PowerShell
cursed, 2012-02-20 18:21:57

About sh, bat and binary files?

I'm not familiar with this kind of programming.
Found a script like this:

#!/bin/bash

function die() {
    echo "$1"
    exit 1
}

# Taken from Debian Developers Reference Chapter 6
function pathfind() {
     OLDIFS="$IFS"
     IFS=:
     for p in $PATH; do
         if [ -x "$p/$*" ]; then
             IFS="$OLDIFS"
             return 0
         fi
     done
     IFS="$OLDIFS"
     return 1
}

pathfind "java" || die "[ERROR] could not find: java in \$PATH"

exec java -jar $0 "[email protected]"


PK.... тут идет 200кб бинарных данных просто скопированных в скрипт, которые не вставляются в поле браузера.

Those. java is called here, which is passed a JAR file. Essentially, you need to pass the path to the file. As I understand it, in a similar way bash allows you to pass the contents of a file, instead of a path.
Please correct me, and explain the logic of work on your fingers, and also tell me how to do this for Win.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
cursed, 2012-02-20
@cursed

Thanks to all. Under Windows, at random, it turned out like this:

@echo off & java -jar %0 %* & exit /b 0 ... и дальше пихаем бинарник

V
Vitaly Peretyatko, 2012-02-20
@viperet

In fact, this script is designed to turn the *.jar Java application into a UNIX executable file.
Those binary data at the end of the PK ... and so on - this is the JAR, that is, the Java classes in the ZIP archive.
The logic of work here is simple; the script searches the list of paths in the PATH variable for the java program, and if it finds it, it launches it, passing the name of the current script as the name and, as parameters, the parameters with which the script was launched. If java is not found, reports this.

M
mitry, 2012-02-20
@mitry

Under Windows something like this:
@start java %0 %*

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question