unix

how to get magic number of a binary file

there is a magic number associated with each binary file , does anyone know how to retrieve this information from the file? ...

What unix text editor should I learn?

Maybe this should be a community wiki page... What unix text editor should I learn? My co-workers mostly use vi. I am thinking about vim because the syntax highlighting seems appealing. Is there any advantage to vi over vim? I know that there are a lot of emacs fans out there too? Is there any reason to learn a specific editor? ...

Redirecting TCP-traffic to a UNIX domain socket under Linux

Assume a legacy Linux application listening on a UNIX domain socket /tmp/foo. In addition to communicating with this legacy application over the UNIX domain socket mechanism I want to be able to connect to it via a TCP-connection on port say 1234. What is the easiest way to bind to TCP port 1234 and then redirect all incoming connectio...

Linux/Unix Console Graphics/Control

I would like to know how to create console applications with better control of input and output using C. For example, how does the text-editor nano display the file contents in a certain portion of the screen and then keep a list of commands stationary on the bottom. I know you can use the win32 api to do this in Windows, but what is t...

How to include from the very root with PHP

Hi all, I'm building a CMS on a SaaS principle. I have my webserver (dynamic dedicated) up and running. It's all going like expected, but now I've come across my templating system, and later on simple things such as filehandling. Logically, each client has an own hostingaccount. All the hostingaccounts will be requesting to the masterda...

Modifying Text Column Wise with Sed/AWK

I have an input data with three columns (tab separated) like this: a mrna_185598_SGL 463 b mrna_9210_DLT 463 c mrna_9210_IND 463 d mrna_9210_INS 463 e mrna_9210_SGL 463 How can I use sed/awk to modify it into four columns data that looks like this: a mrna_185598 SGL 463 b mrna_9210 DLT 463 c mrna_9210 ...

Running unix scripts in J2EE env?

Can anyone please share their experience of invoking unix scripts from J2EE env, either servlet or EJBs? Note that these scripts are to be invoked for real time processing and not offline processing. ...

how to delete 3 days old files using ftp in a shell script (Solaris OS)

I am working on a script to create files basically replica of some tables and ftp those files to the remote machine.there is one more requirement to delete the 3days old files on the remote machine before dumping these files. I need help in writing the ksh for deleting 3 days old files on a remote machine using ftp ...

UNIX 'comm' utility allows for case insensitivity in BSD but not Linux (via -i flag). How can I get it in Linux?

Hi, I'm using the The excellent UNIX 'comm' command line utility in an application which I developed on a BSD platform (OSX). When I deployed to my Linux production server I found out that sadly, Ubuntu Linux's 'comm' utility does not take the -i flag to indicate that the lines should be compared case-insensitive. Apparently the POSIX s...

Validate if an application is at the server

Hi all, I have an own webserver and for one of my clients I need to be able to search through PDF's. I've asked my hostingprovider to install the xPDF package. Now I've come to testing and I'm calling this line of code in a PHP script: $content = shell_exec('/usr/local/bin/pdftotext test.pdf -'); The only thing is, I'm getting a NULL ...

How to quickly rename a bunch of files in the folder

I have a bunch of files that are named 'something_12345.doc' (any 5-digit number, not necessarily 12345). I need to rename them all to just 'something.doc'. This is a Unix filesystem, and I suspect there's a way to do this with just one command... Can any Unix regular expressions guru help? Thanks! ...

How does getaddrinfo() do DNS lookup?

getaddrinfo() is a function we need to use before creating a socket() or connect()ing, right? Then how does getaddrinfo communicate with DNS server in the first place? PS: Where can I see the complete source of getaddrinfo? ...

Is assembler portable between Linux distros?

Is a program shipped in assembler format portable between Linux distributions (modulo CPU architecture differences)? Here's the background to my question: I'm working on a new programming language (named Aklo), whose modus operandi will be the classic compiling to .s and feeding the result to the GNU assembler. Obviously it would be ni...

Finding Set Complement in Unix

Given this two files: $ cat A.txt $ cat B.txt 3 11 5 1 1 12 2 3 4 2 I want to find lines number that is in A "BUT NOT" in B. What's the unix command for it? I tried this but seems to fail: comm -3 <(sort -n A.txt) <(sort -n B.txt) | sed 's/\t//g' ...

What is the general syntax of a Unix shell command?

In particular, why is that sometimes the options to some commands are preceded by a + sign and sometimes by a - sign? for example: sort -f sort -nr sort +4n sort +3nr ...

Is there a way to make a shell become interactive in the middle of a script?

I'd like to do something like: do lots of stuff to prepare a good environement become_interactive #wait for Ctrl-D automatically clean up Is it possible with bash? If not, do you see another way of doing the same thing? ...

How can I performance test using shell scripts - tools and techniques?

I have a system to which I must apply load for the purpose of performance testing. Some of the load can be created via LoadRunner over HTTP. However in order to generate realistic load for the system I also need to simulate users using a command line tool which uses a non HTTP protocol* to talk to the server. * edit: actually it is HTT...

cygwin & cygcheck

Hi All, I want to know about cygcheck utility of cygwin. How can I use it to extract all the class hierarchy and dependencies with the help of cygwin? Thanks ! P.S: Any tutorial that you can point out that shows how to use it for dependencies ...

Unix makefile error: 'make: Fatal error: Don't know how to make target '

I have the simplest of makefiles: threads: gcc threads.c -o threads but I get the error: 'make: Fatal error: Don't know how to make target' Any ideas what I am doing wrong? It's probably something simple - I made the makefile in emacs on the system which is trying to run it (Unix) ...

How to compare filesizes on Windows and Linux with ascii?

I'm working on a Python script that will upload a bunch of files to an FTP site. To check to see whether the file has changed, I'm comparing file sizes. The problem is, the files I'm uploading have \r\n line endings, but transferring via FTP (ascii mode to a Linux box) converts to \n line endings. Obviously I'm losing a bunch of bytes in...