0

I need to create a file (in my java source code) that will be able to execute a bash script without having to have the user type chmod 755...in their terminal. I tried command files, but it still asked me to give the file permission. Thanks

I have tried command files, exe files, jar files, etc

import java.io.*;
import java.util.*;
public class twint2 {
    public static void main (String [] args)throws FileNotFoundException{
                 File bash = new File ("/Users/garrettpartenza/Desktop/myScriptss.command");
                    PrintStream out = new PrintStream (new FileOutputStream(bash));
                        out.println("#!/bin/bash");
                        out.println("twint -u realDonaldTrump -s china -o /Users/garrettpartenza/Desktop/file.csv");

        }
    }

It downloads the command file, but it still needs permission to execute.

1 Answers1

2

To execute the file, try doing bash file.bash in the terminal.

You can also set file permissions in your Java program to allow it, by doing bash.setExecutable(true);.

vityavv
  • 1,482
  • 12
  • 23