Bash 使用参数从java程序调用脚本shell
我想将此shell脚本称为:Bash 使用参数从java程序调用脚本shell,bash,Bash,我想将此shell脚本称为: #!/bin/sh exiftool -a -u -g1 -j videos/$filename > metadata/$filename1.json; #!/bin/sh filename=$1 filename1=$2 exiftool -a -u -g1 -j videos/$filename > metadata/$filename1.json 来自java程序。我试试这个: File dir = new File("videos")
#!/bin/sh
exiftool -a -u -g1 -j videos/$filename > metadata/$filename1.json;
#!/bin/sh
filename=$1
filename1=$2
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+"");
}
}
File dir=新文件(“视频”);
String[]children=dir.list();
如果(children==null){
//目录不存在或不是目录
System.out.print(“不存在el directorio\n”);
}否则{
对于(int i=0;i您需要在shell脚本中检索参数:
#!/bin/sh
exiftool -a -u -g1 -j videos/$filename > metadata/$filename1.json;
#!/bin/sh
filename=$1
filename1=$2
exiftool -a -u -g1 -j videos/$filename > metadata/$filename1.json
这就是问题所在!!非常感谢!