I have arraylist of filenames (java) and I want to delete these files using rm but it is time consuming can I do batching using xargs or something else which can help to delete files faster. Answer Don’t use rm. Use Java. As others have pointed out, spawning a process is much slower than doing it in your program. Also,
Tag: shell
Why am I getting IOException : “Cannot run program ./shellScript.sh error = 2, No such file or directory in Java?
The following Main.java code simply tries to simulate the following linux command: The program below works only if the executable Main.jar sits within /dir1/dir2, not outside of /dir1/dir2. How do I modify the program below so that Main.jar can sit anywhere on the file system? Answer You should use ProcessBuilder to launch or one of the overloads of exec. You
Unable to load config data to springboot application from mounted volume in kubernetes
I have springboot application and I am trying to load additional configuration from a volume mounted location /tmp/secret-config.yaml and getting below error: java.lang.IllegalStateException: Unable to load config data from ‘/tmp/secret-config.yaml’ I do not want to use configmap or secrets for this. It’s a simple json file which I am trying to load. I am trying to pass it like this
Converting Shell Script to Dockerfile
I have Java app and want to generate docker image, I have shell script like this: And I try to convert it into Dockerfile like this It can be generated, but there’s an error when I try to run it like this: I’ve also changed this script RUN for rJarFile in `ls ${APPLICATION_DIR}/lib/*.jar`; do export into this RUN for rJarFile
Sha256 checksum difference between Java vs Linux
Am writing a application which calculate the checksum of file before sending it to downstream. At downstream application, linux shell script are used to process the files. It is noticed that checksum calculated from Java application doesn’t matches that calculated using Linux command ‘sha256sum’. Below is code snippet in JAVA: Using java api i get checksum value as : but
Command is Not Interpreting in Java [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 2 years ago. Improve this question I have this block; And when I execute it, nothing happens. It sometimes
Unix shells: How to ensure command works against most common shells?
I have some java code which uses jsch to connect to our unix servers and run below command. ls -lt /tempdirectory/ grep -v ‘^do | grep “$”(date ‘+%b %e’)” | head -1 | awk ‘{print %9}’ …
Unable to create a folder by executing a shell script using java
I was trying to execute shell scripts using java code. The following is a sample code to demonstrate the issue : The shell script file test1.sh that I am trying to execute : I am getting echo message and was able to print in the java console indicating that the shell script is executed successfully. But no directory is being
Executing multiple commands over SSH “exec” channel on firewall device with Java JSch does not work
I referred the question Multiple bash commands and implemented as below. I am connecting to a device for which first command should be configure then only I will get a prompt to execute all other commands. I don’t get output for any of the commands and the control does not return. The following are the commands that work in terminal.
How to execute shell command using SFTP channel in JSch?
I am trying to list all *.xml files in the directory. I do a cd first and then was trying to execute: But not sure how exactly to do it. There were some example around the Exec channel but is there a way to do the find with SFTP itself? Answer Your requirements are conflicting. You cannot execute shell commands