not able to Execute shell script containing executable through android app - java

I have designed one android application in which i want to invoke shell script which in turn executes one executable(i have place both(script and executable) of them in assets folder).
My executable takes one argument as hex number
when i executes shell script through adb shell from my linux(ubuntu) manually, it is working fine but when application does try to execute that executable through script it is not working(not giving even error message).
here is script part;
/data/data/com.example.test/program 0x950000
Thanks in advance.

Related

Mulesoft cannot run a shell script

I am trying to run a shell script in a flow in Mulesoft's Anypoint Studio.
While I can get some basic shell to run I cannot get my script to run. This is what my script looks like:
#!/bin/ksh
export JWHome=${pwd}
export LOG4J_JAR=$JWHome/lib/log4j-1.2.7.jar
export CLASSPATH=$JWHome/lib/java.jar:$LOG4J_JAR:$JWHome
I set the above script as a payload and execute it from a Groovy script by running:
payload.execute().text
When I run this script I get the following error:
java.io.IOException: Cannot run program "#!/bin/ksh": error=2, No such file or directory
I get the same error when I remove "#!/bin/ksh" - For example when I run Export to set a variable.
How can I get this to run?
I'm assuming that what you did -you didn't provide enough details- is to use a Groovy script to execute the content of a string in the payload using the execute() method. That is failing because a shell script is not a single command. Only a shell can interpret it, but not as command line.
You can try writing the shell script content to a file (example: myscript.sh, or use a temporary name), then execute the shell script by name ("myscript.sh".execute()). You will probably need to add the path to the file is correct otherwise the execute() method may not find it.

Reading python script cmd output when executed by another .exe from cmd

I have written a Java project that uses Runtime.getRuntime.exec() to launch a .exe which then launches a python script.
Within the py script are several 'print(..)' commands that I wish to be read by java using getInputStream(). However, as the script is being launched by another .exe, 'print()' or sys.stdout.write() outputs do not appear in the cmd window. Is there a way to ensure all outputs return to cmd, or is there another way round it?
Thanks in advance!

How to run a JAR file with NOHUP from within a service or bash script

I've want to start a JAR file through a service script file or normal bash script. If I try the following in the command line, it is working all great. The JAR file runs in background and also if I end the SSH session:
nohup /opt/java/jdk8_x32/jre/bin/java -jar /home/test/DoOnLANServerAgent_1.0.0-SNAPSHOT.jar &
If I use exactly the same from within a bash script file, the JAR wouldn't launch and the process is never running. This occurs also, if I use a normal service script in /etc/init.d/myservice. The process won't start, I always have to open up the terminal and manually start the Java program.
Is there any solution for my problem?

How can I run gradle startscript created using installDist task from a batch file in windows OS?

I have Executed the gradle installDist task for my project. After that two start scripts were created one for running in unix like system and another for windows.
I am able to successfully execute the script created for unix systems. But when I tried to run the windows .bat file in my windows system. It is giving below error in command line.
Even if I am trying to run the batch file directly from cmd. It is giving the below error
The input line is too long.
The syntax of the command is incorrect.

Using maven plugin exec-maven-plugin to run a shell script

I have a java web application project. I am using the exec-maven-plugin to execute a shell script which creates a small txt file in a directory when the project is built using mvn clean isntall. I have confirmed that the script is being executed when running mvn clean install by writing test text. However, the script is not creating the txt file.
When the script is run normally through the terminal, ie ./script.sh , the txt file is created correctly.
toTxt="hello"
printf $toTxt > testText.txt
echo 'This shows up, but testText is not created.'
Does anyone know the reason why this is happpening?
Try either echoing pwd command to see where it should create the file or add <workingDirectory>${project.build.outputDirectory}</workingDirectory>
to your configuration block in pom.xml
NOTE: You can specify something other than ${project.build.outputDirectory} to specifically point to the right place. And make sure you have write permissions to it.
Keep in mind that some commands are not really external programs, but shell built-ins. This means that they don't launch programs, and maven-exec-plugin will not be able to run them. However, you can run bash to get the result, just not pwd.
bash -c "echo $(pwd)"
should do the trick. Maven is launching bash which is then running the script echo $(pwd) which calls the bash builtin function pwd and passes the result back (due to the echo).
Yes, it's a lot of work to get around the lack of a pwd program, but that's because there really isn't a pwd program, it's part of the internal offerings of bash.
http://www.tldp.org/LDP/abs/html/internal.html lists the bash internals (builtin commands).

Categories

Resources