unix

TCP Operation Timed Out

I've got a TCP server and client written in C that opens up a connection that should be open forever. On the first send, errno returns 0 which is fine. On subsequent sends it gives me an errno 60 which is that the operation timed out. The packet is still recieved by the server though and nothing seems to be wrong. What could cause the th...

Changing environment variable in UNIX

If we change an environment variable in one process, is the change reflected in other running processes as well? ...

Portable way to achieve ls' -v flag (i.e. sort by version)?

I'm working on a some build scripts that I'd like to depend on only standardized features. I need to sort some files by version. Say the files are bar-1.{0,2,3} bar-11.{0,2,3}. By default, ls gives me: bar-1_0 bar-11_0 bar-11_2 bar-11_3 bar-1_2 bar-1_3 Getting what I want is easy using 'ls -v': bar-1_0 bar-1_2 bar-1_3 bar-11_0 bar-...

How to resolve /var/www copy/write permission denied?

I am a newbie in php, mysql. I have written a hello.php script, which I am trying to copy into /var/www directory (and will later want to open it through web browser). The problem with the same is that I am not allowed to save/write any files in /var/www despite me being the root. I tried implementing steps in this question, but I get th...

How do I find the MAC address programatically on IRIX?

How do I find the MAC address of a network card on IRIX? I'd rather not shell out to something that displays it and parse the output. I'm coding C. Methods that require root access are acceptable. ...

How do I reattach and close multiple screen sessions from a list

I am an Ubuntu 9.04 user. Given a list of screen sessions such as the following: 9076.pts-30.moe (09/27/2009 11:30:08 PM) (Attached) 8778.pts-24.moe (09/27/2009 11:29:46 PM) (Detached) 8674.pts-0.moe (09/27/2009 11:29:25 PM) (Attached) 22649.pts-28.moe (09/27/2009 11:51:46 AM) (Detached) 22543.pts-24.moe (09/27/2009 11:50:56 AM) (Detac...

Cron fails on single apostrophe

The following does work as expected: date +'%d-%b-%Y-%H-%M' 28-Sep-2009-14-28 But none of the following 4 entries from crontab are working. * * * * * date +\'%d-%b-%Y-%H-%M\' >> /backup/shantanu/testing.txt * * * * * date +'%d-%b-%Y-%H-%M' >> /backup/shantanu/testing1.txt * * * * * date +"%d-%b-%Y-%H-%M" >> /backup/shantanu/testing2...

How do I find out my python path using python?

How do I find out which directories are listed in my system’s PYTHONPATH variable, from within a Python script (or the interactive shell)? ...

How do I specify environment variables when making a system call in PHP?

I'd like to call system("foo") in PHP but also specify environment variables that "foo" will have access to when it runs. This is under Linux. Any simple trick for that? ...

Joining Line Breaks With Condition in SED

I have data that looks like this: > sq1 foofoofoobar foofoofoo > sq2 quxquxquxbar quxquxquxbar quxx > sq3 foofoofoobar foofoofoo > sq4 foofoofoobar foofoo I want to join the lines on the basis of ">sqi" header as cut-off line, i.e. yielding: foofoofoobarfoofoofoo quxquxquxbarquxquxquxbarquxx foofoofoobarfoofoofoo foofoofoobarfoofoo ...

I have a file with all the iptable settings. How do I load this into my server?

My system admin gave me a file with iptables rules. What command do I type in to load this? I heard people can do this in one line? Something like...iptables > thefile.dat ???? ...

Best method of triggering a shell script from Java

I have a shell script which I'd like to trigger from a J2EE web app. The script does lots of things - processing, FTPing, etc - it's a legacy thing. It takes a long time to run. I'm wondering what is the best approach to this. I want a user to be able to click on a link, trigger the script, and display a message to the user saying tha...

unix process infinite

Hi, I am wondering what happens in a program that just has a while(1); in the main() function when compiled with g++ on unix. When I run the program, I am seeing 0% cpu usage. Why is this? Shouldn't it hog up the cpu? Is the compiler optimizing this somehow? By putting a yield_processor like system call that context switches out? The ...

How can I keep running a unix program in the background even if I log out?

I want to run a Perl script with some while(1) loop in the background on a unix machine until I kill it. This is a remote computer to which I don't have administrative permissions (so for some reason, I can't use Daemon::Generic::While1), I log to it through SSH, and I want it to continue to run after I log out. One way I found out is ...

Upload clocking script

How can I make a script that, once a day, will upload a file via ftp to several different servers, then take note (in a log) of how much time the uploads took? Thanks to Rajax I have the cronjob set up to execute this so far as the script, let's say it's called ftpScript.sh: #!/bin/sh HOST='ftp.users.qwest.net' USER='MYUSERNAME' PASSW...

How to achive single-processing mode running php scripts?

I have cron job - php script which is called one time in 5 minutes. I need to be sure that previously called php script has finished execution - do not want to mix data that's being processed. There are three approaches I used to apply: Creation of auxiliary text file which contains running-state flag. Executed script analyzes the co...

How do you manage/store/arrange your alias in *nix?

I have a million of alias stored in my .cshrs file. I wonder if it is preferred way or people use other files to do it and then loaded into the environment. How do you do it? ...

Taking up/down arrow as input to a program in Unix

I am implementing my own shell. But to supprt for command history, I need to use monitor up/down arrow key as in standard shells. Please tell me how to handle arrow keys as input or does these keys generate signals? Please elaborate. ...

How can I implement my own basic unix shell in C?

My Shell should understand PATH environment variable. It can be set and modified. It runs in two ways -interactive & batch mode. Shell is capable of taking more than one job like ls;ps;wc file;cal. I know I will have to use execs, forks and pipes but just cant get started. Thank you in advance. Edited: PS:Not a homework question. Newb...

Gnu Makefile - Handling dependencies

What approach do C++ programmers on Unix platform use to create and manage Makefiles? I was using hand made Makefiles for my projects but they don't handle header file changes and other dependencies. I googled around and found a good solution here. But I ran into a problem here in the sed command - sed -e 's/#.*//' -e 's/^[^:]*: ...