To create a gluster volume after successful user registration, let's take a look at how to use Java to call Linux terminal commands.
The source code is as follows:
import java.io.InputStreamReader;import java.io.LineNumberReader;public class RuntimeTest{ public static void main(String args[]){try{ Process process = Runtime.getRuntime().exec ("ls"); InputStreamReader ir=new InputStreamReader(process.getInputStream()); LineNumberReader input = new LineNumberReader (ir); String line; while ((line = input.readLine ()) != null){ System.out.println(line);}catch (java.io.IOException e){ System.err.println ("IOException " + e.getMessage());} }}
References:
1. http://zhidao.baidu.com/question/41907875.html
2. http://www.blogjava.net/envoydada/archive/2007/05/08/115877.html
3. http://blog.csdn.net/HEYUTAO007/article/details/5705499
4. http://blog.csdn.net/bigbuiding/article/details/1675105
5. http://dangflying.blog.163.com/blog/static/8693721820111218320357/
Why can't I execute the sudo gluster command on the terminal by using Objective C? Then I try to put the gluster volume command in the shell script and use crontab to regularly execute the script, the same is found. The sudo gluster command was not executed. Then I added a line of sudo mkdir test to the script and did not execute it. Instead, I changed it to mkdir test, it indicates that the sudo command is used, that is, the user permission problem. Because the gluster command must be executed with sudo, how can we correctly execute the sudo command in the shell script? There are two solutions:
1. Switch to the root mode, that is, the superuser mode can be correctly executed.
2. How do I execute terminal commands under a Super User in normal user mode? The password is free when sudo is used to execute the command, because a common user needs to enter the password after entering the sudo command, which is the password of the current user, save the password and you can execute the superuser command.
References:
1. http://blog.sina.com.cn/s/blog_700132870100t8lj.html
2. http://bbs.chinaunix.net/thread-1916342-1-1.html
If the Linux terminal command has been successfully called in Java, it will be okay if it is placed in JSP.