unix

C++, monitor for keyboard input

Hi, I'm brushing up on my general programing skills and I've come across a snag. I'm writing a program that simulates a colony of bunnys. Once this program starts it is autonomous, however, at any point the user should be able to press the 'k' key to cull the population by half. I can't think of a way to do this without pausing the progr...

What happens in an interrupt service routine?

Can someone please explain to me what happens inside an interrupt service routine (although it depends upon specific routine, a general explanation is enough)? This always used be a black box for me. ...

Question Regarding Dynamic memory allocation

Hello guys, I have questions regarding stacks and dynamic memory allocation. 1) Does kernel determine the size of the stack dynamically during run time or sets the size before the load time ? If stack size is allocated dynamically how can stack overflow take place (Because if size of stack reaches beyond the limit the page handler wil...

Filtering Rows Based On Number of Columns with AWK

I have lines of data that contain single column and two columns. What I want to do is to extract lines that contain only 2 columns. 0333 foo bar 23243 qux yielding only: 0333 foo 23243 qux Note that they are tab separated, even for lines with only one column you have tab at the beginning. What's the way to do it? I tried this...

SSH doesnt exit from command line..

Hi, I ssh to another server and run a shell script like this nohup ./script.sh 1>/dev/null 2>&1 & Then type exit to exit from the server. However it just hangs. The server is Solaris. How can I exit properly without hanging?? Thanks. ...

How to Ctrl-Z in Perl script

Hi, I am writing a Perl script and I need to execute Unix Ctrl-Z on the script. How can I do it in Perl ? thanks. ...

how to automatically and periodically upload a file from a windows machine to a unix server?

hi, i have 2 csv files on my windows machine that i want to transfer to a unix server every hour (because the 2 files are updated every 30min). so i search on the web and i found this possibility: to ftp the files from windows to unix using a batch and task scheduler. i want to know if it's possible to do it from the unix server with ...

file descriptor polling

Hi, I have created a following program in which I wish to poll on the file descriptor of the file that I am opening in the program. #define FILE "help" int main() { int ret1; struct pollfd fds[1]; ret1 = open(FILE, O_CREAT); fds[0].fd = ret1; fds[0].events = POLLIN; while(1) ...

How to find a solaris process with ___ status

I made the following script which searches for certain processes, displays uses pflags for each one, and stops when it finds one with the word "pause": !cat find_pause #!/usr/bin/perl -W use warnings; use strict; if (open(WCF, "ps -ef | grep '/transfile' | cut -c10-15 | xargs -n1 pflags 2>&1 |" )) { while (<WCF>) { ...

objc convert unix date

Hi guys, I got a small problem . I have this date format from .net json output: Date(1280471989140); when I try to convert using + (NSDate*)dateFromUnixDate:(double)unixdate { NSTimeInterval unixDate = unixdate; return [NSDate dateWithTimeIntervalSince1970:unixDate];} but I got the wrong date back,why? thanks ...

Exec real world example

Hi All, I am looking for a real world scenerio where using exec will be the only availble option ( The problem could not be solved if exec is not used) I know what is exec and how it differs from fork, but still intrested in real world problem that enforce the use of exec command. ...

How to specify timezone in linux using C

Hi, I was trying to set the timezone of my system, and was trying to use settimeofday(), which takes a timezone struct as an argument, but just read that that struct is now obsolete (http://linux.about.com/library/cmd/blcmdl2_settimeofday.htm) How could I go about doing this? Thanks in advance. EDIT: Ugh, I feel really stupid. I crea...

In Unix / Bash, is "xargs -p" a good way to prompt for confirmation before running any command?

I have asked how to make any command "ask for yes/no before executing" in the question http://stackoverflow.com/questions/3231804/in-bash-how-to-add-are-you-sure-y-n-to-any-command-or-alias It seems like for the command hg push ssh://[email protected]//somepath/morepath I can also do this: echo ssh://[email protected]...

Kill and restart multiple processes that fit a certain pattern

I am trying write a shell script that will kill all processes that are running that match a certain pattern, then restart them. I can display the processes with: ps -ef|grep ws_sched_600.sh|grep -v grep|sort -k 10 Which gives a list of the relevent processes: user 2220258 1 0 16:53:12 - 0:01 /bin/ksh /../../../../../ws_...

expect command - Unix

Hi, I am using 'expect' to automate ssh password authentication. When I run the script in SunOS, I find the spawned ssh process gets killed once the below script is completed. This is not the case in Linux. How do we avoid it? Should we ignore the SIGCHLD signal somehow? Is there anyway to determine through this script if spawned proces...

Unix cut command taking an unordered list as arguments

The Unix cut command takes a list of fields, but not the order that I need it in. $ echo 1,2,3,4,5,6 | cut -d, -f 1,2,3,5 1,2,3,5 $ echo 1,2,3,4,5,6 | cut -d, -f 1,3,2,5 1,2,3,5 However, I would like a Unix shell command that will give me the fields in the order that I specify. ...

Tutorial for debian software packaging

I want to learn about debian source packaging.Is there any good tutorial for that.Please give your suggestions. ...

Secure chmod privileges?

The standard chmod privileges are "644" for files and "755" for directories, aren't they? In most cases, PHP doesn't need to write to files or directories. So couldn't I take the write privileges from all groups? I could assign "444" to all files and "555" to all directories. Wouldn't that be more secure? Thanks in advance! Note: ch...

Recursively remove filename suffix from files in shell

When we develop locally, we append ".dev" or ".prod" to files that should be made available only to the development/production server respectively. What I would like to do is; after deploying the site to the server, recursively find all files with the ".dev" suffix (for example) and remove it (renaming the file). How would I go about do...

sed, environment variable and date problem

I want to add a timestamp to server events and store the result in a log. My first idea was : ( ./runServer.sh ) | sed "s/.*/`date +%s` & /" | xargs -0 >Server.log 2>&1 & But it seems sed never reevaluates the date, so all events get the same timestamp. Now I'm trying to get around that using environment variable but I can't find ...