int n = Integer.parseInt(nlines);
array = new ArrayList();
for (int i =1; i<=n;i++)
array.add(""+i);
//start of Beanshell code
String lfn = LFN_text_protocol.substring(LFN_text_protocol.indexOf("/grid"));
Process p1 = null;
String srmTimeout = "300", connectTimeout="30", sendReceiveTimeout="900", bdiiTimeout="30";
String localName="proto.txt";
Runtime rt = Runtime.getRuntime();
String[] cmd1 = new String[12];
cmd1[0] = "lcg-cp";
cmd1[1] = "--connect-timeout";
cmd1[2] = connectTimeout;
cmd1[3] = "--sendreceive-timeout";
cmd1[4] = sendReceiveTimeout;
cmd1[5]="--bdii-timeout";
cmd1[6] = bdiiTimeout;
cmd1[7] = "--srm-timeout";
cmd1[8] = srmTimeout;
cmd1[9] = "-v";
cmd1[10] = "lfn:" + lfn;
cmd1[11] = "file:"+localName;
p1 = rt.exec(cmd1);
p1.waitFor();
BufferedReader in = new BufferedReader(new InputStreamReader(p1.getInputStream()));
String line = "";
while ((line = in.readLine()) != null) {
System.out.println(line);
}
BufferedReader err = new BufferedReader(new InputStreamReader(p1.getErrorStream()));
String lineerr = "";
while ((lineerr = err.readLine()) != null) {
System.out.println(lineerr);
}
p1.getErrorStream().close();
p1.getInputStream().close();
p1.getOutputStream().close();
if (p1.exitValue() != 0) {
throw new Exception("Problem downloading file " + lfn);
}
String textKey="lmf emission";
Scanner awk = new Scanner(new File(localName)).useDelimiter(textKey);
if (awk.hasNext()) {
ccs_file_name = awk.next();
if (awk.hasNext())
ccs_file_name = (awk.next().trim().split("\n"))[0];
else throw new Exception("Cannot find string \""+textKey+"\" in text protocol");
}
else throw new Exception("Cannot find string \""+textKey+"\" in text protocol");
awk.close();
textKey="process_number";
awk = new Scanner(new File(localName)).useDelimiter(textKey);
if (awk.hasNext()) {
process_number = awk.next();
if (awk.hasNext())
process_number = (awk.next().trim().split("\n"))[0];
else throw new Exception("Cannot find string \""+textKey+"\" in text protocol");
}
else throw new Exception("Cannot find string \""+textKey+"\" in text protocol");
awk.close();
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy_HH:mm:ss");
String result = dir+"/"+(dateFormat.format(System.currentTimeMillis()));
out=basedir+"/"+relative_dir;