unix

How do I use cp to copy one directory to new name repeatedly and correctly?

I am writing a makefile. However except for the path expansion and restrictions on what I can do, this is basically a shell scripting question. As part of the make process, I want to copy a directory to the destination. My source directory and destination directory are variables, so I can't assume a lot about them. They may be fully qual...

How to securely remember a login password for scripted web queries?

I'm looking at scripting parts of my workflow, which involves interacting with some web-services via SOAP and XML-RPC queries. I'm scripting using bash and python. I need to authenticate against these web services, and I'd ideally like to do so without having to type in my password for every request (typing it once per login would be...

What happens when a process is forked?

I've read about fork and from what I understand, the process is cloned but which process? The script itself or the process that launched the script? For example: I'm running rTorrent on my machine and when a torrent completes, I have a script run against it. This script fetches data from the web so it takes a few seconds to complete. D...

Is Unix coded in C or C++ or both?

Many system calls in Unix use overloading and default variables. This concept is absent in C, so Unix is coded in C++ also right? ...

File mirroring solution for a website

Our website is currently experiencing high volume download traffic. It will soon exceed the bandwidth limit. What's the most convenient way to mirror a software package? We also need to maintain existing URL of the package. ...

script unable to find directories/files when running from qsub cluster script

I'm calling several unix commands and python on a python script from a qsub shell script, meant to run on a cluster. The trouble is that when the script executes, something seems to go awry in the shell, so that directories and files that exist are not found. For example, in the .out output files of qsub I see the following errors: cd...

UNIX Shell-scripting: UDV

I am writing a simple unix shell script: #!/bin/bash # abort the script if a command fails set -e # abort the script if an unitialized shell variable is used set -u i = 0; while [$i -l 1] do src/meshpro input/martini.off video/noise/image$i.off -noise $i src/meshvi...

Identifying and removing null characters in UNIX

I have a text file containing unwanted null characters. When I try to view it in I see ^@ symbols, interleaved in normal text. How can I: a) Identify which lines in the file contains null characters? I have tried grepping for \0 and \x0, but this did not work. b) Remove the null characters? Running strings on the file cleaned it up, bu...

Remove identical files in UNIX

Hi all, I'm dealing with a large amount (30,000) files of about 10MB in size. Some of them (I estimate 2%) are actually duplicated, and I need to keep only a copy for every duplicated pair (or triplet). Would you suggest me an efficient way to do that? I'm working on unix. Thank you :-) ...

naming a screen session in linux

Hi, I am running multiple screens from one ssh connection, when I list all of the screens via screen -ls the names are not very descriptive and when I have multiple screens it becomes hard to remember what is running on each. Does anyone know how to name these sessions (preferably when creating the screen). Thanks ...

How to run python scripts on your server?

Hi, I have mod_python installed on my server, but if I want to acceses a python script - let's say httü://site.com/something.py the script doesn't run, the download box "pops up" Any solutions? ...

Tricking a Unix Commandline Program into Accepting a File Stream

Hypothetical situation. I have a command line program in *nix (linux, BSD, etc.). It was written so that you pass it a text file as an argument $ program file.txt Run the program, it looks at the text in file.txt. Is it possible to "trick" this program into accepting input from a file stream rather than reading a file via disk? ...

Performing grep operation in tar files with out extracting

I have list of files which contain particular patterns. But , those file have been tarred. Now I want to search the pattern in the tar file . And to know which are file contain pattern. without extracting it. Any idea....? ...

Unix alias command not working as expected

i have a command to kill some processes as below: kill -9 `psu|grep MF1pp|grep -v grep|awk '{print $2}'` the command works perfectly fine >psu|grep MF1pp|grep -v grep|awk '{print $2}' 29390 29026 $>kill -9 `psu|grep MF1pp|grep -v grep|awk '{print $2}'` $>psu|grep MF1pp|grep -v grep|awk '{print $2}' when i create an alias as below a...

how can't I redirect the output of time command

I tried to redirect the output of the time command , but I couldn't $time ls > filename real 0m0.000s user 0m0.000s sys 0m0.000s In the file i can get the output of the ls command not the time Please explain me , wny I couldn't and how can I ? ...

How to view some data in gvim without saving it first?

For example suppose I do a certain man or maybe a grep. I want to see the results using gvim without the normal procedure of saving them first and opening the saved file [because I don't need the results once I view them] I tried two ways, both the methods fail: a) man gcc | gvim //opens a blank gvim window b) man gcc > gvim //sa...

Running the shell scripts in Background

Hello, I would to give the user the feature to run the shell script in background. My shell program instantiates a number of other shell scripts. Here is a small code snippet of my script ./main.sh # Main script in main.sh I call preprocessing.sh create_dir.sh handle_file.sh post_processing.sh report_generation.sh I would like t...

send output to file from within shell script

I'm creating a script for users to run. I need to redirect the output to a file I'm creating from inside the script (hostname-date). I have all the pieces except for how to copy the output of the script from inside the same script. All the examples I can find call the script and > it into the log, but this isn't an option. -Alex ...

Need help implementing simple socket server using GIOService (GLib, Glib-GIO)

I'm learning the basics of writing a simple, efficient socket server using GLib. I'm experimenting with GSocketService. So far I can only seem to accept connections but then they are immediately closed. From the docs I can't figure out what step I am missing. I'm hoping someone can shed some light on this for me. When running the follo...

How can I make the watch command interpret vt100 sequences?

Consider this simple example (which displays in red): echo -e "\033[31mHello World\033[0m" It displays on the terminal correctly in red. Now consider: watch echo -e "\033[31mHello World\033[0m" It does not display the color. Note: I am aware that it is easy to write a loop that mimics the basic behavior by clearing and rerunning. How...