unix

What's an easy way to automate logging into a server and tailing a log?

I would like to save the keystrokes I make to ssh into a server (with a ssh public key) and tail a log file. What's the easiest way to do this. Is there a shell script that can do this, or if not, a short Ruby script? ...

How to create required file name in unix using shell script

I am reading one property file which contains some file paths using shell script. Now depending on this file path I want to create name of zip file. Something like this...My property file contents:: path=tmp/inputs/logs/abc path=tmp/backup/inte/xyz destpath=abc/xyz Now I am able to create file name as abc.zip and xyz.zip as: paths=`g...

global variable but still can't acess in linux

Hi, i have trying to use some global variable in my ant file. when i do login through terminal. i can acess those variable like JAVA_HOME but when i am trying to acess variable through the ant command i am not able to find them. global variable declared in .cshrc setenv JAVA_HOME jdk_full_path ant code using variable. <property...

command not found error message after I try to run a UNIX script.

I'm learning how to make shell scripts in UNIX, but I keep coming across this stupid error. Let's say I make a script like this: #!/bin/sh echo HELLO I save the file as test, and make the command executable by me with chmod 700 test. I save the file in my home directory, and (attempt) to run the file like so: ./test Only for UNIX t...

processes in g++

hello everyone, can somebody please explain what exactly is going on when I do in my Unix > g++ -o hello hello.cpp and > g++ hello.cpp what is the difference? Only renaming from a.out to hello? thanks in advance ...

Is it good to open multiple ports on TCP server?

The Tcp server need to serve many clients, If one client one server port and one server thread to listen the port, I want to know weather it is faster ? If one port is good, could someone explain the different between one port and multiple ports in this case, thanks! ...

Specify input date format for /bin/date

I'm creating Unix bash script that parses web-server log file and inserts this data into database. So I need to convert timestamp which has format "05/Oct/2010:07:38:40 +0400" into "YYYY-mm-dd". I've tried to use /bin/date -d, but it does not accept given format. I could not find a way to specify input date format for this tool. Is is p...

Index a bunch of text files

Hi community, I have to search a huge number of text files (all over a Unix server disks') for a given string (I have to). Given the time and resources this will take, I'm thinking coming out with the list of files that do contain the token in question is a meager result, compared to the investment. This feels wrong. Considering that ...

grep invert search with context

I want to filter out several lines before and after a matching line in a file. This will remove the line that I don't want: $ grep -v "line that i don't want" And this will print the 2 lines before and after the line I don't want: $ grep -C 2 "line that i don't want" But when I combine them it does not filter out the 2 lines befor...

how to perform automated Unix input?

How can you set a string to be used instead of standard input? For example, when running the latex command in Unix it will always find some trivial errors, to skip through all errors you have to enter "r" into the command line (I now know that with latex specifically you can use -interactionmode nonstopmode, but is there a more general s...

To discuss on demerits of nohup.out specially related to process speed or space

Will nohup.out consume space / make the server slow if a shell is allowed to run in infinite loop in server using the command: "nohup ./shell & > nohup.out" I had written a small program in shell script that will run in infinite loop, (since I don't have privilege to add my script in crontab) and the output of the same is of 4 lines whi...

Viewing Unix Log Files

We are having a discussion at work, what is the best UNIX command tool that to view log files. One side says use LESS, the other says use MORE. Is one better than the other? ...

Good book for Unix Internals

Hi all, am very much interested in unix. Want to learn in and out. Can you guys help me by listing some books which can make me a wizard? Ultimately I want to become a unix programmer. I am not a novice user in Unix. ...

In unix, how can I pipe the output of who into the groups command?

I'm trying to do something like this: Say there are 4 users logged into a UNIX machine, a, b, c, and d. Now, to get the groups these guys belong to, I have to type out : groups a b c d. What I am wondering, is if there is a way to do something like who | groups where I can pipe the users currently logged-in to the groups command, wh...

Print STDOUT in the middle of 2 Pipes in Solaris(bash)

http://www.webdesignerdepot.com/rss.htm I have the same issue. This command: ./somescript.sh > ../log/scriptlog.log requires the output of a command go to std out. but inside the script command | mailx -s "Subject" [email protected] what I would like to do is something like : command | tee > /dev/stdout | mailx -s "Subjec...

unix shell set command

Want to know what set -A option does in the below command? XMLOUTFILE=${XMLOUTDIR}/${TEST_ID} set -A FILES "${XMLOUTFILE}" ...

How can I merge two files?

I have two files File 1: 7118 7457 7591 7539 8001 File 2: 5003 5008 5011 5026 5028 5029 5031 Output that i need 7118,5003 7457,5003 7591,5003 7539,5003 8001,5003 7118,5008 7457,5008 7591,5008 7539,5008 8001,5008 so on..... ...

Anonymous Structures in C found in Unix Kernel

I have started reading the Lions Commentary on Unix v6. I came across these snippets, which I have never seen used in the C language. The author does provide some sort of an explanation, but could someone explain to me what is happening here? params.h : SW 0177570 ...... struct { int integ; }; and this used in unix/prf.c if(SW->int...

C++: how to convert date string to int

Hi I need a procedure that convert string time to int. Which support all this formats under unix: "Wed, 09 Feb 1994 22:23:32 GMT" -- HTTP format "Thu Feb 3 17:03:55 GMT 1994" -- ctime(3) format "Thu Feb 3 00:00:00 1994", -- ANSI C asctime() format "Tuesday, 08-Feb-94 14:15:29 GMT" -- old rfc850 HTTP form...

I'm having trouble performing arithmetic expressions in UNIX.

I have the following script: #!/bin/sh r=3 r=$((r+5)) echo r However, I get this error: Syntax error at line 3: $ unexpected. I don't understand what I'm doing wrong. I'm following this online guide to the letter http://www.unixtutorial.org/2008/06/arithmetic-operations-in-unix-scripts/ ...