Archive for the ‘windows’ Tag
execute shell command via java
It happened to me that working via an extranet on a citrix environment in a WSAD workspace, that I needed to remove the attribute to at least 200 files in different directories.
Since do it one by one via WSAD is unthinkable, and I didn’t have time to going to the client, loggin into the net in order to have a shell and I dind’t have a shell by my hands, I did it via java.
The environment is Windows machine and here is the source
package tests.runners;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
public class ShellCommandRunner {
public static void main(String[] args) throws IOException{
OutputStream stdin = null;
BufferedReader br = null;
String line = null;
String command = null;
command = "cmd.exe /C attrib -r /S /D X:\\workspaces\\tuc-workspace\\*.*";
System.out.println(command);
Process p = Runtime.getRuntime().exec(command);
stdin = p.getOutputStream(); //use this to push commands
//processing stdout
br = new BufferedReader(new InputStreamReader(p.getInputStream()));
while((line=br.readLine())!=null) System.out.println(line);
//processing stderr
br = new BufferedReader(new InputStreamReader(p.getErrorStream()));
while((line=br.readLine())!=null) System.err.println(line);
System.out.println("done!");
}
}
Make an ISO image
Here is how to create an ISO image (file .iso) on your hard disk. Useful when needed to make multiple copy of a CD. The following example starts create it directly from CD but since in Linux everything is a file…
mkisofs -D -o ~/my-cool-cd.iso /cdrom
the -D option allow the deep ISO9660 directory nesting.
You can easily use this command even from windows by installing the cygwin with the mkisofs package.
UPDATE
The command above it’s a bit strict. In order to create a more “relaxed” cd-rom you could use the following command
mkisofs -l -D -N -relaxed-filenames -V “Volume Label” -o ~/my-cool-cd.iso /cdrom
Here the options:
- -l: Allow full 31-character filenames. Normally the ISO9660
file-name will be in an 8.3 format which is compatible with MS-DOS,
even though the ISO9660 standard allows filenames of up to 31
characters. If you use this option, the disc may be difficult to
use on a MS-DOS system, but will work on most other systems. Use
with caution. - -D: Do not use deep directory relocation, and instead just pack them in
the way we see them. If ISO9660:1999 has not been selected, this
violates the ISO9660 standard, but it happens to work on many
systems. Use with cau- tion. - -N: Omit version numbers from ISO9660 filenames. This violates the
ISO9660 standard, but no one really uses the version numbers anyway.
Use with caution. - -relaxed-filenames: Allows ISO9660 filenames to include all 7-bit
ASCII characters except lowercase letters. This violates the ISO9660
standard, but it happens to work on many systems. Use with
caution.
Windows XP: no dialtone
Configuring a modem in Windows XP for those like me used to use Debian can be a bit non trivial.
I got the Error 680: no dial tone. I know that it’s easy to solve this problem, just disable the “wait for dialtone” and put one comma before the number (wait for a second before dial). The non trivial part is to find where I can tell it. So, here it is:
Start->Settings->Control Panel->System and click on the Hardware tab and then on Device Manager.
Then select the modem from the list of devices. Right click and properties. Now on the Modem tab uncheck the Wait for dialtone
Leave a Comment
Comments (2)
Leave a Comment