I have created a jar file , it reads from standard input and print them out to the standard output.
Below is how you can use the app:
cat /ephemeral/test/input | java -jar /ephemeral/test/Hello.jar >> /ephemeral/test/output
I am wondering is it possible to add my Hello.jar to be a Linux Command, let's say -hello-:
So next time I could just do something like:
hello /ephemeral/test/input /ephemeral/test/output
I am not that much familiar with Linux Soft Link and Java, so any help or information would be appricated!
UPDATE: thanks for reno's inspiring answer, I put the cat ... | .. >> .. into a shell script hello.sh. Now I can do something like:
./hello.sh /inputpath/input outputpath/output
(Note: you should not use $0, $0 is actually the name the file itself instead of input arguments)
Now, the last question is how could you access the shell script EVERYWHERE, like how you call basic shell cmds: ls..cat..echo..
I have read a tutorial described exactly what I want(reach to the end of the tutorial directly):
I created a bin folder which is like mkdir /home/ubuntu/bin and put my shell script there. However, I still have problem do what the author described:
hello input output (in my case)
Does anyone know what is going wrong here?
执行此操作的方法是编写包含必要的java -jar
命令的shell脚本(通常为hello.sh
)。
you can write a shell script say test.sh and copy your code to test.sh
cat $0 | java -jar /ephemeral/test/Hello.jar >> $1
and execute the script by passing your input and output file name something like this:
test.sh /ephemeral/test/input /ephemeral/test/output
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.