So I have a Java file that needs this following string to run.
java --classpath=$CLASSPATH:/path/to/jradius-client.jar net.sourceforge.jradiusclient.TestRadiusClient hostname authport acctport shared-secret username password
What I need to do is to write a script that uses space separated words from a certain textFile.txt
and use each of the words in place of shared-secret
. If it's a success, print the word.
What I have till now is:
#!/bin/bash
java --classpath=$CLASSPATH:/path/to/jradius-client.jar net.sourceforge.jradiusclient.TestRadiusClient "val" 1812 1813 shared-secret username password
exit $?
What I want is something like this (in Java like pseudo-code, I have no bash experience :( ):
String s = Words From Text File As String
String[] words = s.split("\\W+");
for(word : words){
try and run The JAva .jar File With Params X, Y, word, Z
success? print word
}
How can I achieve this? Thanks.