有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

bash error=13,在Java中执行脚本时权限被拒绝

我有一个Java代码,它在执行时会向用户显示一个GUI按钮,然后按下它;将执行一个bash脚本。我的脚本在终端上工作,但当我试图通过运行时在Java中运行脚本时。getRuntime()。执行官,我收到权限错误。我在命令中也使用了chmod 777,但都是徒劳的

**MY Java code is** 
package com.interface_saad;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import java.io.File;
/**
 *
 * @author Saad
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    static JFrame fr=new JFrame("QoS");
    static JPanel button_pan=new JPanel();
    static JButton QoSButton=new JButton("QoS");

    public static void main(String[] args) throws IOException {

    final File file = null;

        button_pan.add(QoSButton);
        fr.add(button_pan,BorderLayout.CENTER);
        fr.setVisible(true);
        fr.setSize(200,200);

 QoSButton.addActionListener(new ActionListener() {
       public void actionPerformed(ActionEvent e) {
                try {
                    System.out.println("path");
                    Runtime.getRuntime().exec("chmod 777 /home/talal/enable.sh");
                    Runtime.getRuntime().exec("./ /home/talal/enable.sh");

                } catch (Exception ex) {
                    System.out.println(ex);
                }


            }
        });


        fr.setDefaultCloseOperation(fr.EXIT_ON_CLOSE);
    }

}

并且我的bash脚本是启用的。上海

#!/bin/sh

(sleep 2
echo root
sleep 2
echo admin
sleep 1

echo '/usr/sbin/svqos status `get_wanface` 0'
sleep 2


echo '/usr/sbin/svqos `nvram get wshaper_downlink` `nvram get wshaper_uplink` `get_wanface` `nvram get wan_mtu` 0 '

sleep 1
echo '/usr/sbin/svqos status `get_wanface` 0'

sleep 4) | telnet 192.168.1.1 -l root 

我需要建议。我急需帮助


共 (0) 个答案