Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 使用参数从java程序调用脚本shell_Bash - Fatal编程技术网

Bash 使用参数从java程序调用脚本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")

我想将此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"); 
    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

这就是问题所在!!非常感谢!