unix

In Python script, how do I set PYTHONPATH?

I know how to set it in my /etc/profile and in my environment variables. But what if I want to set it during a script? Is it import os, sys? How do I do it? ...

How can I import the enviroment variables of a completed process in python?

I need to write a python script that launches a shell script and import the environment variables AFTER a script is completed. Immagine you have a shell script "a.sh": export MYVAR="test" In python I would like to do something like: import os env={} os.spawnlpe(os.P_WAIT,'sh', 'sh', 'a.sh',env) print env and get: {'MYVAR'="test"...

How to unzip CAB file with ActiveX on unix system?

I tried to use unzip, bunzip2, gunzip. But none of these tools can unzip CAB file. ...

Command line utility: how to make it right?

I have several question: If there is an error which has to be displayed to the client - It is a good thing to use STDERR stream instead of STDOUT? Or is it a trivial issue? I want to add color support to output messages of this utility. Do I have to use some environment-tolerant framework for that?(it can be 256 color mode and "pure" o...

how to rewite a particular block of file

hello guys I want to rewrite a particular block in a file but its not working for me For example if I want to rewrite to offset 4 of the file I used lseek(fd,4,SEEK_SET) and called write system call but its writing at the end of the file instead of at offset 4. Can someone please help me. ...

connect to oracle (AIX unix version) from windows using c#

Hi, I have an oracle 9i db installed on IBM AIX unix. This server is a remote server. I can connect it through Putty and SQL DEVELOPER. REQUIREMENT 1) Want to connect to it from my windows application using c#. 2) Cannot install anything on oracle unix. So, how can i connect using c#? Please suggest some solution. Thanks ...

Unix invoke script when file is moved

Hi. I have tons of files dumped into a few different folders. I've tried organizing them several times, unfortunatly, there is no organization structure that consistently makes sense for all of them. I finally decided to write myself an application that I can add tags to files with, then the organization can be custom to the actual orga...

How to get a list of files that match some pattern?

How to get a list of files that match some pattern if filenames may contain \n character? Update: I want solution in pure vimscript, so that it will depend on nothing but vim. Update2: Expected output of glob function Consider the following script: :!touch /test ; mkdir /test$'\n' ; touch /test$'\n'/test :echo glob('/**/test') /test...

Unix uniq utility: What is wrong with this code?

What I want to accomplish: print duplicated lines This is what uniq man says: SYNOPSIS uniq [OPTION]... [INPUT [OUTPUT]] DESCRIPTION Discard all but one of successive identical lines from INPUT (or stan- dard input), writing to OUTPUT (or standard output). ... -d, --repeated only print duplicate lines This is what I try to exe...

Can PowerShell (or script) on Windows / Mac / Ubuntu list file / directory structure easily?

Can PowerShell on Windows by itself or using simple shell script, list files and directory this way: (or using Mac OS X or Ubuntu's shell script) audio mp3 song1.mp3 some other song.mp3 audio books 7 habits.mp3 video samples up.mov cars.mov Unix's ls -R or ls -lR can't seem to list it in a tree structure unf...

Comparing two files in Unix

I have got 2 files which have got n number of lines. eg: File 1 465466454 546545454 5454454 Data=4545454545484848484 kuh uytyer huihkuh File 2 e4654sdfdsf 544hjklhjl 464jku Data=4545454545484848484 kuh uytyer huihkuh As you can see both files have got the same data after the place "Data=" (this "Data=" occurs only once in the file)...

Tips to write thread-safe UNIX code?

What are the guidelines to write thread-safe UNIX code in C and C++? I know only a few: Don't use globals Don't use static local storage What others are there? ...

What happens if during a signal handling in UNIX, the same signal gets sent to the program?

Any ideas on this? Is there some kind of a signal queue, or does it get dropped? While we are at this question, is it true that signal handlers should do as minimal work as possible? I read somewhere that a signal handler should use a pipe and just write one byte to it, indicating what the program should do. Then somewhere else the pro...

How to run context-aware commands in Python?

I want to write some python package installing script in Python into virtualenv. I write a function for installing virtualenv def prepareRadioenv(): if not os.path.exists('radioenv'): print 'Create radioenv' system('easy_install virtualenv') system('virtualenv --no-site-package radioenv') print 'Activate...

Image folder download using wget

i need to write a line in my script to download a directory(having about 10 images)from a url like abc.com/Image/images/,trying wget command as below in the script : wget -e robots=off -r -l1 --no-parent -A.gif http://abc.com/Image/images/ OR wget -A "*.gif" http://abc.com/Image/images/ but it is giving error as : HTTP request sent, ...

shell built in pwd versus /bin/pwd

Hi, I would like to know the code implementation of built-in pwd and /bin/pwd especially when the directory path is a symbolic link. Example: hita@hita-laptop:/home$ ls -l lrwxrwxrwx 1 root root 31 2010-06-13 15:35 my_shell -> /home/hita/shell_new/hita_shell hita@hita-laptop:/home$ cd my_shell hita@hita-laptop:/home/my_shell$ pwd...

How do I make this change in my VIM config?

Control + Right = end Control + Left = home Control + down = page down COntrol + up = page up I want these to work, regardless of what mode (insert or not) I'm in. What do I put into my .vimrc? ...

clearing the contents of a file in c

Hello guys, I would like to know how the contents of a file can be cleared in c. I know it can be done using truncate but I dont find any source clearly describing it. Thanks & Regards, Mousey ...

Binary installation file

Hi, i am not really getting an idea on how a .bin file is being created. The JDK for Linux platform ships in the form of binary executable file (jdk-6u20-linux-i586-rpm.bin); how can one create such deliverable for their own project? Please give me some directions. Thanks, -Vijay ...

sed regexp in a bash script

Hello! I want to extract a certain part of a string, if it exists. I'm interested in the xml filename, i.e i want whats between an "_" and ".xml". This is ok, it prints "555" MYSTRING=`echo "/sdd/ee/publ/xmlfile_555.xml" | sed 's/^.*_\([0-9]*\).xml/\1/'` echo "STRING = $MYSTRING" This is not ok because it returns the whole string. I...