unix

Running daemon through rsh

I want to run program as daemon in remote machine in Unix. I have rsh connection and I want the program to be running after disconnection. Suppose I have two programs: util.cpp and forker.cpp. util.cpp is some utility, for our purpose let it be just infinite root. util.cpp int main() { while (true) {}; return 0; } forker.cp...

Command passed as argument to shell script

Hi, I want to pass a command to a shell script. This command is a grep command. While executing I am getting the following errors, please help: myscript.sh "egrep 'ERROR|FATAL' \*20100428\*.log | grep -v aString" myscript.sh is a simple script: #!/bin/ksh cd log $1 the errors are: egrep: can't open | egrep: can't open grep egre...

How to remove carriage return and linefeed in combination from unix file.

I have a file in Unix in which I am getting carriage return (^M) followed by linefeed.There are many other newline (enter) within the file which are not followed by linefeed.I want to remove this carriage return (^M) followed by linefeed such that other newline which are not followed by linefeed are not affected .Can you please suggest a...

In a process using lots of memory, how can I spawn a shell without a memory-hungry fork()?

On an embedded platform (with no swap partition), I have an application whose main process occupies most of the available physical memory. The problem is that I want to launch an external shell script from my application, but using fork() requires that there be enough memory for 2x my original process before the child process (which wil...

UNIX—ASCII files appear to be binary

I've just tried to hg diff some C source files and was told that they are binary. So, my question is: How can I convince UNIX and Mercurial that these files are, in fact, ASCII? Thanks in advance for your help. ...

Convert Unix Epoch Time to format HH:MM:SS without the date

I'm using SSRS 2005 and I need to convert time from a serial unix time like 3412.254263 to a duration like 166:12:35 where the second format is HH:MM:SS. All .NET code should work, but I can't find any function that does not include the date or does not treat the result as a duration. Any help would be appreciated! ...

Maximum file size given a particular inode structure?

Suppose a UNIX file system has some constraints--say, 2 KB blocks and 8B disk addresses. What is the maximum file size if inodes contain 13 direct entries, and one single, double, and triple indirect entry each? ...

Creating multiple process and simulation in C via fork()

i want to create multiple process groups which will call different functions. i write the code below. firstly i want to get following output ./fork 4 5 I am a child: 1 PID: 22330 I am a child2: 1 PID: 22334 I am a child: 2 PID: 22331 I am a child2: 5 PID: 22338 I am a child: 4 PID: 22333 I am a child: 3 PID: 22332 I am a child2...

Bash script to append dynamic file path to existing .ini file possibly using sed?

Hello everyone, i have a commonly named .sqlite file contained within many unique user's home folders with file structure: /home/user/unique-ip-address/folder/file.sqlite I've decided to move all of these .sqlite files to a tmpfs mount and have already done so maintaining the full directory structure, so each .sqlite file is now in: /mnt...

How can I output a UTF-8 encoded XML file with unix line-endings from ActivePerl on Windows?

I'm running ActivePerl 5.8.8 on WinXP. I'd like to output an XML file as UTF-8 with UNIX line endings. I've looked at the perldoc for binmode, but am unsure of the exact syntax (if I'm not barking up the wrong tree). The following doesn't do it (forgive my Perl - it's a learning process!): sub SaveFile { my($FileName, $Contents) = ...

zsh alias within function

Good morning, In zshell I have an alias as follows: alias foo='echo FooBar!' Which of course works fine. I have a function wherein I'm trying to actually 'execute' the alias, where it doesn't. foo_fun () { echo "About to foo!" `$foo` $foo eval $foo eval `$foo` echo "Just food...wait what?" } I'm having a b...

using bash: write bit representation of integer to file

Hullo First, I want to use bash for this and the script should run on as many systems as possible (I don't know if the target system will have python or whatever installed). Here's the problem: I have a file with binary data and I need to replace a few bytes in a certain position. I've come up with the following to direct bash to the o...

Unix diff ignoring lines starting with a sequence

How can I diff two files and ignore lines starting with a sequence. E.g File1: abc def time:123 File2: igh def time:345 With unix diff it will report <time:123 >time:345 I want to ignore this diff. Any ideas? ...

unix - how to deal with too many args for cat

I have a bunch of files in a directory, each with one line of text. I want to cat all of these files together (all the one liners) into a single, large file. However, when I use cat there are too many arguments. How can I get around this? ...

Installing software on Solaris

I'd like to install several unix utilities (incl. xmlstarlet, wget) on a solaris 10 machine which I don't have root access to (obviously, I have a user account). I'm not that experienced with solaris and am wondering if I can simply get hold of an uber binary for each utility I need and just place this in my home directory? Is this feasi...

syslog: on ubuntu, how to configure rotation and gzip'ing of syslog files?

how do you configure rotation of syslog log files on ubuntu? in my /etc/syslog.conf, i have this line: local1.* /var/log/log.txt over time, the following backup files have appeared: /var/log/log.txt.0.gz /var/log/log.txt.1.gz how do i configure how often these files get generated, and how to clean them out? ...

How do I use Perl to parse the output of the sqlplus command?

I have an SQL file which will give me an output like below: 10|1 10|2 10|3 11|2 11|4 . . . I am using this in a Perl script like below: my @tmp_cycledef = `sqlplus -s $connstr \@DLCycleState.sql`; after this above statement, since @tmp_cycledef has all the output of the SQL query, I want to show the output as: 10 1,2,3 11 2,4 Ho...

Unix diff to only print relevant diff

I have these two files File: 11 11 456123 File: 22 11 789 Output of diff 11 22 2c2 < 456123 --- > 789 Output to be < 456123 > 789 I want it to not print the 2c2 and --- lines. I looked at the man page but could not locate any help. Any ideas? The file has more than 1000 lines. ...

What is profiling in unix?

Hi, Can anybody tell me about 'profiling' in unix by giving a small example. Thank you! ...

What is call out table in unix?

Hi, Can anybody tell me what a 'call out table' is in Unix? Maurice J. Bach gives an explanation in his book Design of the UNIX Operating System, but I'm having difficulty in understanding the examples, especially the one explaining the reason of negative time-out fields. Why are software interrupts used there? Thanks! ...