2010-06-30 41 views
2

腳本殼,我想調用這個shell腳本:調用Java程序與參數應用

#!/bin/sh 
exiftool -a -u -g1 -j videos/$filename > metadata/$filename1.json; 

從Java中的一個程序。我試試這個:

File dir = new File("videos"); 
    String[] children = dir.list(); 
    if (children == null) { 
     // Either dir does not exist or is not a directory 
     System.out.print("No existe el directorio\n"); 
     } else { 
      for (int i=0; i<children.length; i++) { 
       // Get filename of file or directory 
       String filename = children[i]; 

       //Recojo el momento exacto 
       Process p = Runtime.getRuntime().exec("/home/slosada/workspace/Hola/Metadata.sh "+filename+" "+filename+""); 

      } 

     } 

但是我的電腦被封鎖,我什麼都做不了。另外,沒有輸出文件。
也許,問題在於我如何調用腳本以及如何傳遞參數文件名。

任何幫助?

在此先感謝

回答

1

你需要你的shell腳本中檢索參數:

#!/bin/sh 
filename=$1 
filename1=$2 
exiftool -a -u -g1 -j videos/$filename > metadata/$filename1.json 
+0

那是poroblem! 非常感謝! – 2010-07-01 07:29:48