unix-programming

First Come, First Served process scheduling

i have 4 processes: p1 - bursts 5, priority: 3 p2 - bursts 8, priority: 2 p3 - bursts 12, priority: 2 p4 - bursts 6, priority: 1 Assuming that all processes arrive at the scheduler at the same time what is the average response time and average turnaround time? For FCFS is it ok to have them in the order p1, p2, p3, p4 in the executi...

Linux Shared Memory

The function which creates shared memory in *inux programming takes a key as one of its parameters.. What is the meaning of this key? And How can I use it? Edit: Not shared memory id ...

FTP to SFTP in shell scripting

This script is to connect to different servers and copy a file from a loaction defined. It is mandatory to use sftp and not ftp. #!/usr/bin/ksh -xvf Detail="jyotibo|snv4915|/tlmusr1/tlm/rt/jyotibo/JyotiBo/ jyotibo|snv4915|/tlmusr1/tlm/rt/jyotibo/JyotiBo/" password=Unix11! c_filename=import.log localpath1=`pwd` for i in $Detail ...

getting started with lex

I need to format some hexdump like this: 00010: 02 03 04 05 00020: 02 03 04 08 00030: 02 03 04 08 00010: 02 03 04 05 00020: 02 03 04 05 02 03 04 05 02 03 04 08 ‍ to 02 03 04 05 02 03 04 08 02 03 04 02 03 04 05 02 03 04 05 02 03 04 05 02 03 04 remove the address fields, if present remove any 08 at the end of a paragraph (followed ...

Tracing UNIX signal origins?

If I have a process that receives signals from other processes, is there a way for me to somehow tell which process (if any) sent a signal? strace lets me trace which signals a process has received, but doesn't allow me to trace who issued them. ...

How do you tell if a string contains another string in Unix shell scripting?

Hi all, I want to write a Unix shell script that will do various logic if there is a string inside of another string. For example, if I am in a certain folder, branch off. Could someone please tell me how to accomplish this? If possible I would like to make this not shell specific (i.e. not bash only) but if there's no other way I can m...

math library in gcc

I am writing a program on linux gcc... When I tried to include <math.h> I found that I need to link math library by using command gcc -lm But I am searching for another way to link the math library 'in code', that does not require the user to compile using any options.. Can gcc -lm be done in c code using #pragma or something? EDIT:...

Communicating between a parent and its children

Newbie question: On Unix, in a program with a parent and some children: - How can the parent alert the children efficiently to do some work.. ? - Or how can the children wait for parent signal to start doing some work? EDIT: This program tries to do a complex computation in parallel, I have already used shared memory as a common works...

shell script output in html + email that html

Using Solaris I have a monitoring script that uses other scripts as plugins. Theses pugins are also scripts which work in difffernt ways like: 1. Sending an alert while high memory uilization 2. High Cpu usage 3. Full disk Space 4. chekcking the core file dump Now all this is dispalyed on my terminal and I want to put them in a HTML f...

unix message queue

Is there an ipc option to get the last message in message queue but not removing it? I want this to allow many clients reading same messages from the same server.. Edit: Server and clients are on the same machine! Thanks ...

how to use aspell in cmd line

i need to use aspell or any other spell checking in cmd line program i need to check for an single word only not on a file.... ...

How do I write to a file and print to a terminal concurrently in Unix?

I have a little bash function to log my Macports outputs to a file (since installs often spew little tidbits that are easy to lose in terminal noise), then I just cat the file to the terminal: function porti { command sudo port install $@ >> $1.log 2>&1; cat $1.log } Is there a way to do this concurrently? BTW I pass $@ to instal...

How to number the ls output in unix?

I am trying to write a file with format - "id file_absolute_path" which basically lists down all the files recursively in a folder and give an identifier to each file listed like 1,2,3,4. I can get the absolute path of the files recursively using the following command: ls -d -1 $PWD/**/*/* However, I am unable to give an identifier ...

Killing a process

I have a for loop to get the list of PID's and kill each PID. I want to display the entire line of PS output and write it to the /tmp/outfile . But from each line of PS output each field(PID,PPID,...) is written along with a new line in the /tmp/outfile. So if PS output has three lines as output i want to log these three lines into ...

collect the value returned by netstat into a variable

netstat -an | grep hypen echo $variable hypen | wc -l How to collect the value of netstat -an | grep echo $variable | wc -l to a varibale conn_count. ...

How to add the number of active netstat connections of different machine?

I've written this code to get the connections from one machine and adding them with the number of connection of the other machine. This code is not giving any netstat, 0 is coming for the live active connections. #!/usr/bin/ksh -xvf Machine_Detail="prpm@sp204|LC1_R11_LCP|LC1_R12_LCP|LC1_FR15_LCP|LC1_R16_LCP prpm1@sp2048|LC1_R13...

Regarding Shell variable

I need to call another shell script testarg.sh within my main script. This script testarg.sh has arguments ARG1 ,ARG2, ARG3. I need to call up the below way: ./testarg.sh -ARG1 <value> -ARG2 <value> -ARG3 ARG1 and ARG3 arguments are mandatory ones. If it's not passed to the main script then I quit. ARG2 is an optional one. If the ...

Regarding PID Shell Script

I am calling another shell script testarg.sh within my main script. the logfiles of testarg.sh are stored in $CUSTLOGS in the below format testarg.DDMONYY.PID.log example: testarg.09Jun10.21165.log In the main script after the testarg process gets completed i need to grep the log file for the text "ERROR" and "COMPLETED SUCCESSFULLY...

Regarding grep in solaris

I want grep for a particular work in multiple files. Multiple files are stored in variable testing. TESTING=$(ls -tr *.txt) echo $TESTING test.txt ab.txt bc.txt grep "word" "$TESTING" grep: can't open test.txt ab.txt bc.txt Giving me an error. Is there any other way to do it other than for loop ...

BASH Script to Check if a number is Armstrong or Not

Hi, I was writing a script to check if a number is Armstrong or not. This is my Code echo "Enter Number" read num sum=0 item=$num while [ $item -ne 0 ] do rem='expr $item % 10' cube='expr $rem \* $rem \* $rem' sum='expr $sum + $cube' item='expr $item / 10' done if [ $sum -eq $num ] then echo "$num is an Amstrong Number" else echo "$num ...