public static boolean isRunning(String procName) {
boolean found=false;
String command="";
if (System.getProperty("os.name").contains("Windows")) {
command="tasklist";
} else {
command="ps ax";
}
try {
Runtime r = Runtime.getRuntime();
Process p = r.exec(command);
p.waitFor();
BufferedReader br = new BufferedReader (new InputStreamReader (p.getInputStream()));
while (br.ready()) {
if (br.readLine().contains(procName))
found=true;
}
} catch (InterruptedException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
} finally {
return found;
}
}
понедельник, 25 апреля 2011 г.
Java: how to test, run or not some process in your system?
понедельник, 18 апреля 2011 г.
How I get eth0 ip address
hostname -I|sed -e 's/\s.*//g'
If you have any better idea - write it in comments please. Also, if anybody knew how to get external ip address, write it too.
Updated:
ifconfig eth0|grep 'inet '|sed -e 's/[A-Z,a-z,:]//g;s/^\s*//g;s/\s.*//g'
if you're get fear from regexp:
ifconfig eth0|grep 'inet addr'|sed -e 's/[A-Z,a-z,:]//g'|awk '{print $1}'
If you have any better idea - write it in comments please. Also, if anybody knew how to get external ip address, write it too.
Updated:
ifconfig eth0|grep 'inet '|sed -e 's/[A-Z,a-z,:]//g;s/^\s*//g;s/\s.*//g'
if you're get fear from regexp:
ifconfig eth0|grep 'inet addr'|sed -e 's/[A-Z,a-z,:]//g'|awk '{print $1}'
пятница, 8 апреля 2011 г.
How to get domain administrator privilegies in Windows Server 2003 / 2008
That we need:
- Physical access to the server
- ERD Commander CD (or other with Locksmith utility)
- Head + Hands
Your actions:
- Insert CD and boot from ERD Commander
- Use locksmith to get privilegies of local administrator
- Reboot
- Boot windows server in directory restore mode
- Login with your local admin username and password
- Put cmd.exe, srvany.exe and instsrv.exe in C:\tools (or some other directory)
- Run cmd.exe
- cd C:\tools
- instsrv PassRecovery C:\tools\srvany.exe
- Set autorun to this service (in Settings panel or write services.msc) (PassRecovery)
- Run regedit
- Create subfolder Parameters in HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\PassRecovery
- Add keys (String): Application (C:\tools\cmd.exe) and AppParameters (/k net user administrator (name of domain administrator) Pa$$w0rd (new password, must be match to security policy) /domain)
- example: /k net user admin Pa$$w0rd /domain
- In service settings in tab log on enable checkbox Allow Service to interract with desktop, apply.
- Reboot
- Run
- Enjoy.
среда, 6 апреля 2011 г.
Open/LibreOffice as service in unix
soffice -headless -nofirststartwizard -accept="socket,host=localhost,port=8100;urp;StarOffice.Service"
пятница, 1 апреля 2011 г.
How to get linecount in your project
find ~/project_directory/src -type f -name *.java -exec cat {} \; | wc -l
Подписаться на:
Комментарии (Atom)