shell

comparing csv files

I want to write a shell script to compare two .csv files. First one contains filename,path the second .csv file contains filename,paht,target. Now, I want to compare the two .csv files and output the target name where the file from the first .csv exists in the second .csv file. Ex. a.csv build.xml,/home/build/NUOP/project1 eesX.ja...

assigning value to shell variable using a function return value from Python

hi, I have a Python function, fooPy() that returns some value. ( int / double or string) I want to use this value and assign it in a shell script. For example following is the python function: def fooPy(): return "some string" #return 10 .. alternatively, it can be an int fooPy() In the shell script I tried the followin...

LaTeX: Which OS am I running on?

I’m writing a LaTeX package which needs to use \write18. Some of the shell commands I issue are system-specific (e.g. rm vs. del). Is there a way to determine what system I’m running on? It would be enough to disambiguate between Windows and other (Unix-like) systems. ...

How to change colors programmatically in Konsole based on current directory?

I currently use a color scheme based on which directory that I'm working in. I manually open up a Konsole shell and then cd into a directory and got to Settings and change the color scheme. What I would like to do is have Konsole automatically set its foreground and background colors based on which directory I'm in. Basically if I'm i...

Shell extension installation not recognized by Windows 7 64-bit shell

I have a Copy Hook Handler shell extension that I'm trying to install on Windows 7 64-bit. The shell extension DLL is compiled in two separate versions for 32-bit and 64-bit Windows. The DLL implements DLLRegisterServer which adds the necessary registry entries. After adding the registry entries, it calls the following line of code to...

PHP - Execute an external command, but by passing an array, one for programme name, then arg1, then arg2, etc...

I have a PHP script that needs to execute programmes that will work on files that have spaces in the names. Most PHP functions for executing external commands (e.g. exec()) take an 1 string argument for the command line to execute. However then you have to do things like escapeshellarg() to make your input safe. Is there some way to exe...

How to make sh script the application for Mac OS

I wrote java application and i need to make it standalone for macos(.app). Earlier I used jar builder, but now i need to execute some shell script before java application starts. How can i do it? ...

DB load CSV into multiple tables

UPDATE: added an example to clarify the format of the data. Considering a CSV with each line formatted like this: tbl1.col1,tbl1.col2,tbl1.col3,tbl1.col4,tbl1.col5,[tbl2.col1:tbl2.col2]+ where [tbl2.col1:tbl2.col2]+ means that there could be any number of these pairs repeated ex: tbl1.col1,tbl1.col2,tbl1.col3,tbl1.col4,tbl1.col5,tb...

Rearrange columns using cut

Hi, I am having a file in the following format Column1 Column2 str1 1 str2 2 str3 3 I want the columns to be rearranged. I tried below command cut -f2,1 file.txt The command doesn't reorder the columns. Any idea why its not working? Thank you. ...

Shell script to stop a java program

Is there a way to stop a java program running using a shell script by knowing the name alone.I am using ksh shell ...

Getting two erl shells to talk

I want to be able to have two Erlang shells to talk. I'm running on OS X. I tried the tut17 example here: http://ftp.sunet.se/pub/lang/erlang/doc/getting_started/conc_prog.html I've also tried: $ erl -sname foo and then in a new Terminal: $ erl -sname bar (bar@elife)1> net_adm:ping(foo@elife). pang Any ideas? ...

Using shell versus eshell whenever an Emacs action needs to spawn a shell in a new buffer

I'm using Rinari for Rails development in Emacs. M-x shell will open a new buffer that is correctly PATH'd for my environment (zsh). M-x eshell uses all the incorrect PATH's and I haven't been able to get it to play nicely with anything. There's a function of Rinari that fires up an instance of a web server for the Rails app I'm editi...

getting a program to return immediately at the command line so it's not tied to the shell that launched it

Hi everyone, Some programs return immediately when launched from the command line, Firefox for example. Most utilities (and all the programs I've written) are tied to the shell that created them. If you control-c the command line, the program's dead. What do you have to add to a program or a shell script to get the return-immediately b...

Output to a text file the pre-compiler code

Hello, gcc 4.4.2 c89 I have a file called main.c. I want the result of the pre-comiler and save it to a text file. I have done the following which creates a text file, but there is nothing in it. It is zero bytes. gcc -E main.c | > main.txt Many thanks for any suggestions, ...

How to correctly save the unix top command output into a variable?

I've got to save the output of the top command into a variable and I do this: myvar=`top -b -n1 | head -n 18` The problem is that it seems to be ignoring the return characters, so when I echo the content of $myvar I see something like: top - 15:15:38 up 745 days, 15:08, 5 users, load average: 0.22, 0.27, 0.32 Tasks: 133 total, 1 runn...

How can I create a shell with history in my Perl program?

I'm writing a tool that is executed as a shell in Perl. I want it to have a history, so that if you press the up arrow, you go back to the previous command, just like bash or other shells. How should I go about this? -- EDIT -- Thanks to daxim for pointing me towards Term::ReadLine::Gnu. I was able to get it to work on my Linux box and...

Shell script: send sed output to mysql?

Trying to pipe the output of a sed replacement on a text file into MySQL like so: mysql -D WAR | sed -e "s/2000/$START/g" -e "s/2009/$END/g" < WAR.sql That's not working. Nor is: mysql -D WAR < sed -e "s/2000/$START/g" -e "s/2009/$END/g" < WAR.sql What's the proper solution here? ...

How to get output of shell in MySQL ?

In linux I can use ! to start a shell command: mysql >\! ping localhost Is there a way to get the output of shell in MySQL? ...

call function at specific time intervals in Linux

What is the best way to call a function inside a Linux daemon at specific time intervals, and specific time (e.g. at 12am every day, call this function). I'm not referring to calling a process with crontab, but a function within a long running daemon. Thanks ...

/bin/sh: How to redirect from &3 to named pipe?

I have a background process read from named pipe. for example mkfifo /tmp/log.pipe ./myprog.sh < /tmp/log.pipe I want to use &3 instead of specify /tmp/log.pipe echo "aaa" >&3 but results similar to echo "aaa" > /tmp/log.pipe How can I redirect &3 to /tmp/log.pipe everytime. ...