unix

How to run a ksh script from java code?

I tried to run a shell script from java code, but I am facing problem. The script is in batchstart.sh file - #!/bin/ksh export DISPLAY=:0.0 Now the script is run with a dot on the command line -- . batchstart.sh How do I run it from java? My java code is below. It throws the following exception - java.io.IOException: .: not found ...

Is there a way to determine if a subdirectory is in the same filesystem from python when using os.walk?

I'm writing a python script that uses os.walk() to walk a directory tree. I'd like to give it the ability to skip subdirectories that are mounted to a different file system, the way find -xdev does. Checking through the documentation on os.walk(), I didn't see any argument to pass in for it to do that automatically. Is there something...

In a Unix Environment, is there a way to programmatically call Which in C?

For a project in C, we need to build a shell over a Unix server. It needs to be able to execute functionality native to Unix, and not bash (or any other Unix shell). I am writing a method in the hopes to generalize a call to a command. into a general function: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/wa...

Fix for 'return' in cakePHP to return Value from view controller funtion

Hi there I have a function inside of a view function inside of a model class in the model.php file that looks like this function sqlToUnix($date){ $YMDThenHMS = explode(" ", $date); $YMD = explode("-", $YMDThenHMS[0]); $HMS = explode(":", $YMDThenHMS[1]); $UnixTime = mktime($HMS[0], $HMS[1], $HMS[2], $YMD[1], $YMD[2], $...

C / C++ program connecting to 32-bit DB2 and 64-bit DB2 simultaneously

Is it possible to successfully author a C / C++ program in *IX operating systems that operates on both 32-bit and 64-bit DB2 implementations simultaneously? The exact requirement is to read from a 32-bit DB2 database and write into a 64-bit DB2 database. ...

What is the native way to create a shortcut (.LNK file) from the Windows XP command line?

EDIT! Sorry to change the question on everyone, but I am really just asking: How do I create a shortcut (.LNK) file from the command line with as little outside help as possible? I really don't want to run a VBscript or to download a program to do it for me. Is it really that hard? Thanks to everyone who provided exceptional answers...

How do you start Unix screen command with a command?

According to the docs for the Unix "screen" command, you can configure it in .screenrc to start with a bunch of default screens, each running a command that you specify. Here's my cofig: # Default screens screen -t "shell_0" 1 screen -t "autotest" 2 cd ~/project/contactdb ; autotest It will not run the autotest command. That window ...

line-end agnostic diff?

I'm working on a mac, with some fairly old files. Different files were created by different programs, so some of them end with \r (mac) and some with \n (unix). I want to be able to run commands like diff, grep, etc on these files, but the ones that have \r are treated as one giant line. does anyone know of a version of diff, grep, etc...

Print Epoch Time in Different Languages

As you may know, tonight, at exactly 23:31:30 UTC, Epoch Time will reach 1234567890! Hurray! One way of watching epoch time is by using Perl: perl -le 'while(true){print time();sleep 1;}' Can you do the same in another programming language? ...

How do I make Windows file-locking more like UNIX file-locking?

UNIX file-locking is dead-easy: The operating system assumes that you know what you are doing and lets you do what you want: For example, if you try to delete a file which another process has opened the operating system will usually let you do it. The original process still keeps it's file-handles until it terminates - at which point th...

How to write an X11 app that follows the cursor

I'd like to write a Linux screen magnifier that's customized to my liking. Ideally, the magnified window would be a square about 150 pixels wide that follows the mouse cursor wherever it goes. Is it possible to do this in X11? Would it be easier to have an application window that follows the mouse around, or would it be better (or possi...

Is there a way to make mv create the directory to be moved to if it doesn't exist?

So, if I'm in my home directory and I want to move foo.c to ~/bar/baz/foo.c , but those directories don't exist, is there some way to have those directories automatically created, so that you would only have to type mv foo.c ~/bar/baz/ and everything would work out? It seems like you could alias mv to a simple bash script that would c...

Any video lectures about Unix and Computer Networking??

Hi,I need some videos lectures to learn them myself because I am not a computer science student. Can you share some with me? Thanks. ...

What directory is '~' when I type 'cd ~' ?

I'm only new to using SSH, but when I log in I end up in the directory ~, which in general is the same directory when FTPing in. I can still go to /, but I don't know what the ~ means. Home? Where is it in relation to /, or how could I find out? ...

How can I put $HOME/opt/git/bin to my PATH?

I tried to include the following unsuccessfully to my ~/.profile: export PATH='$HOME/opt/git/bin' It seems not to work because $git gives me nothing. I am trying to install Git. I have also tried commands here. ...

Open system call

Hi guys, I'm studying for my operating systems midterm and was wondering if I can get some help. Can someone explain the checks and what the kernel does during the open() system call? Thanks! ...

What do you think about the new Debian release cycle?

I was surprised to know that Lenny already promoted to "stable" - among some of my clients there is some fear that Debian would want to compete with Ubuntu for the desktop and forget its server devotion. "Only" 2 years between 4.0 Etch and 5.0 Lenny is unprecedented in Debian time scale. Version inflation? is it because SPARC-32 support...

Repeat a unix command every x seconds forever.

There's a builtin unix command repeat whose first argument is the number of times to repeat a command, where the command (with any arguments) is specified by the remaining arguments to repeat. For example, % repeat 100 echo "I will not automate this punishment." will echo the given string 100 times and then stop. I'd like a similar ...

How to let humans and programs access the same file without stepping on each others' toes.

Suppose I have a file, urls.txt, that contains a list of URLs I'm monitoring. My monitoring script edits that file occasionally, say, to indicate whether each URL is reachable. I'd like to also manually edit that file, to add to or change the list of URLs. How can I allow that such that I don't have to think about it when manually edi...

What do 'real', 'user' and 'sys' mean in the output of time(1)?

$ time foo real 0m0.003s user 0m0.000s sys 0m0.004s $ What do 'real', 'user' and 'sys' mean in the output of time? Which one is meaningful when benchmarking my app? ...