unix

What happens when the controlling terminal's cable is pulled out?

I am trying to handle a signal(if it exists/is sent) when an application's controlling terminal's network cable is pulled out. I tried with these signals, but I guess they aren't: SIGHUP SIGINT SIGTERM I guess in such a case, the server treats the termianl(who's cable was pulled out) just to be in an inactive state. Please su...

Difference between API and ABI

I am new to linux system programming and I came across API and ABI while reading Linux System Programming. Definition of API : An API defines the interfaces by which one piece of software communicates with another at the source level. Definition of ABI : Whereas an API defines a source interface, an ABI defines the low...

Want to know whether enough memory is free on a linux machine to deploy a new application.

I have got a linux machine whose memory snapshot when I do /proc/meminfo is : MemTotal: 16413388 kB **MemFree: 48296 kB** Buffers: 193600 kB Cached: 1986448 kB SwapCached: 874512 kB Active: 15034264 kB Inactive: 713672 kB HighTotal: 0 kB HighFree: 0 kB LowTotal: 16413388...

Bash script process name regex

I'm trying to regex process id's based on parts of a process name. It seems to work if I only do a single word, but it fails when I try to do something like: find me any process with path /beginning ** /endswiththis/ Here's what I have so far: QUEUE_PID="$(ps -ef | grep endswiththis | grep -v $0 | grep -v grep | awk '{ print $2 }')"; ...

how to change directory using exec command from C program?

Hi, I have to change working directory from my C program. For this I have used the following command: execl("/bin/cd","cd","..",(char*)0); but this command is not changing the directory? Is anything wrong in this command or is there any other way to change working directory from C program? ...

How to convert text file to lowercase in UNIX (but in UTF-8)

Hello, I need to convert all text to lowercase, but not using the traditional "tr" command because it does not handle UTF-8 languages properly. Is there a nice way to do that? I need some UNIX filter so I can process this in a pipe. ...

How to get the modified environmental variables using c programme in Mac using bash terminal

Hi, I want to get the modified environment variables using C programme in Mac using bash terminal how to get it? if i use getenv i will get only the default system defined environment variables but i am not getting the modified one. how to get it ...

Shell Script (bash/ksh): 20 seconds to read a variable

Hi guys, I need to wait for an input for 20 seconds, after that myscript should continue the execution. I've tried using read -t20 var however this works only on bash. I'm using ksh on Solaris 10. Can someone help me please? EDIT: 20 seconds is only an example. Let's pretend it needs to wait for 1 hour. But the guy could or could not ...

Can I determine if the terminal interprets the C1 control codes?

ISO/IEC 2022 defines the C0 and C1 control codes. The C0 set are the familiar codes between 0x00 and 0x1f in ASCII, ISO-8859-1 and UTF-8 (eg. ESC, CR, LF). Some VT100 terminal emulators (eg. screen(1), PuTTY) support the C1 set, too. These are the values between 0x80 and 0x9f (so, for example, 0x84 moves the cursor down a line). I am...

bash: Grab fields 5 and 7 from a Unix path?

Given paths like this: /data/mirrors/third-party/centos/5/projectA/x86_64 /data/mirrors/third-party/centos/5/projectA/i386 /data/mirrors/third-party/centos/5/projectA/noarch /data/mirrors/third-party/centos/4/projectB/x86_64 /data/mirrors/third-party/centos/4/projectB/i386 /data/mirrors/third-party/centos/4/projectB/noarch /data/mirrors...

C: fscanf and character/string size

Hello. I am parsing a text (css) file using fscanf. The basic goal is simple; I want to pull out anything that matches this pattern: @import "some/file/somewhere.css"; So I'm using fscanf, telling it to read and discard everything up to a '@' character and then store everything until it reaches a ';' character. Here's the function that...

how to pass a package to libnet(1.1)?

I hava captured some packages by libpcap and built ip header. The package is a const u_char type and named payload, so how to pass the payload to libnet , then I can forward the payload to another ip ? which libnet api can work for this ? ...

UNIX: Calling exec on the parent process after a fork

Hello, I am writing in my grammar, in LEX, some code to fork() my process and run a child. The child actually gets some input from the parent, and then returns a result. I need to call exec on the same binary that loaded the parent, but there I am having an issue. I know that exec does not mean complete sense, but I do this because I h...

Echo All Palindromes, in C

I love the ideas presented in Brian Kernighan and Rob Pike's book, "The UNIX Programming Environment," where they focus on the point of working within an environment where you can put together many (small, precise, well understood) programs on the command line to accomplish many programming tasks. I'm brushing up on strict ANSI C conven...

Running Java UI program though unix

I want to facilate my client to run java program through UNIX command prompt using some shells. It'll look more effecient if they would be able to give input through some GUI. So it can be tested immedietely. I dont want prefer unix commands fro input. Can somebody tell me how to run Java swing or applet programs in UNIX? ...

delete the first 5 chars on any line of a textfile in Linux

Hello, i need a 1liner to remove the first 5 chars on any line of a text file, but i dont know sed, could anyone help me please? Thanks in advance Chris ...

Perl: Is quotemeta for regular expressions only? Is it safe for file names?

While answering this question regarding safe escaping of filename with spaces (and potentially other characters), one of the answers said to use Perl's built-in quotemeta function. The documentation of quotemeta states: quotemeta (and \Q ... \E ) are useful when interpolating strings into regular expressions, because by default an in...

How to write script output to file and command-line?

I have a long-running Python script that I run from the command-line. The script writes progress messages and results to the standard output. I want to capture everything the script write to the standard output in a file, but also see it on the command line. Alternatively, I want the output to go to the file immediately, so I can use tai...

how i can scan file in unix ?

group of person will upload file to IBM-AIX server (OS = UNIX) and we want to scan this files .... and we have another server (OS = WINDOWS) and we install in this server kaspersky ... now :- 1. how i can scan files on IBM-AIX server (OS = UNIX) ? 2.if step one not availabe how i can scan file by kaspersky on other server (OS = WINDOWS) ...

Interprocess communication on UNIX

Hi all, I have to implement some mechanism in C on SOLARIS 9 SPARC in order to allow interprocess communication. In a nutshell, i have to implement a multithread program where the father of the thread once receive a signal, or whatever you want, has to trigger a set of thread that are in charge of encrypting files. I cannot use some T...