So I have a Linux program that runs in a while(true) loop, which waits for user input, process it and print result to stdout.
I want to write a shell script that open this program, feed it lines from a txt file, one line at a time and save the program output for each line to a file.
So I want to know if there is any command for:
-...
I have the below line in the unix shell script. I want to exclude test.jar in WEB-INF/lib being added to the CLASSPATH. How can i do it?
for file in WEB-INF/lib/*jar ;
do
CLASSPATH=$CLASSPATH:$PWD/$file
done
...
From the wrapper shell scripts i am calling the Java program. I want the Unix shell script to pass all the arguments to java program except the
EMAIL argument. HOW Can i remove the EMAIL argument and pass the rest of the arguments to the java program. EMAIL argument can come at any position.
valArgs()
{
until [ $# -eq 0 ]; do
...
I have a variable which has the directory path along with file name. I want to extract the filename alone from the unix directory path and store it in a variable
fspec="/exp/home1/abc.txt"
...
Is there any POSIX signals that I could utilize in my Perl program to create event-driven programming? Currently, I have multi-process program that is able to cross communicate but my parent thread is only able to listen to listen at one child at a time.
foreach (@proc) {
sysread(${$_}{'read'}, my $line, 100); #problem here
chomp($l...
Lets say within my program I want to execute two child processes, one to to execute a "ls -al" command and then pipe that into "wc" command and display the output on the terminal. How can I do this using pipe file descriptors so far the code I have written: An example would be greatly helpful
int main(int argc, char *argv[]) {
int pipef...
Hello
I have tried to do fork() and piping in main and it works perfectly fine but when I try to implement it in a function for some reason I don't get any output, this is my code:
void cmd(int **pipefd,int count,int type, int last);
int main(int argc, char *argv[]) {
int pipefd[3][2];
int i, total_cmds = 3,count = 0;
int in = 1;...
Does anyone see a problem with this, its not working saying bad file descriptor not sure why?
pipe(pipefd[0]);
if ((opid = fork()) == 0) {
dup2(pipefd[0][1],1);/*send to output*/
close(pipefd[0][0]);
close(pipefd[0][1]);
execlp("ls","ls","-al",NULL);
}
if((cpid = fork())==0){
dup2(pipefd[0][1],0);/*read from in...
Okay so I am having this problem. I write up a script to be run in cygwin on Windows. I've tried a bunch of basic example scripts in case it was my scripts problem.
So I tried this:
#!/bin/bash
echo -e "Enter your name and press [ENTER]: \c"
read var_name
echo "Your name is: $var_name"
Then I will run it and I enter a name for var_n...
Why fork() before setsid() to daemonize a process ?
Basically, if I want to detach a process from its controlling terminal and make it a process group leader : I use setsid().
Doing this without forking before doesn't work.
Why ?
Thanks :)
...
I'm writing a program, foo, in C++. It's typically invoked on the command line like this:
foo *.txt
My main() receives the arguments in the normal way. On many systems, argv[1] is literally *.txt, and I have to call system routines to do the wildcard expansion. On Unix systems, however, the shell expands the wildcard before invokin...
I need to calculate an ntp time stamp using gettimeofday. Below is how I've done it with comments on method. Look good to you guys? (minus error checking). Also, here's a codepad link.
#include <unistd.h>
#include <sys/time.h>
const unsigned long EPOCH = 2208988800UL; // delta between epoch time and ntp time
const double NTP_SCALE_FRAC...
I have a file pointer, such as the following:
FILE* f = tmpfile()
How do I use libcurl to do a HTTP POST to a URL as a field named F1?
I tried reading the file contents into a char* array but and used the following to upload:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <curl/curl.h>
#include <curl/types.h>
#...
We have recently installed RHEL 5.4 on some existing 6.2 OS and migrated our code from RH 6.2 to RHEL 5.4. We are facing a difficulty that given a binary (on both OS they have same name) how can we distinguish that which gcc and OS it was build as there are some minor differences in between binary respectively made.
Please help
...
I have a text file with contents as below:
1,A,100
2,A,200
3,B,150
4,B,100
5,B,250
i need the output as :
A,300
B,500
the logic here is sum of all the 3rd fields whose 2nd field is A and in the same way for B
how could we do it using awk?
...
I'd like to run a program on a directory of files. I know how to do this with one file, using
cat myFile.xml | myProgram.py.
How can I run myProgram.py over a folder, say myFolder?
Thanks!
...
how to replace a set of lines in a file with another set of lines in unix ?
#!/usr/bin/ksh
export text1='log_file=$LOG_PATH${UNISON_JOB}".log"'
export text2='\. \$\{env_path\}set_test_log_file\.ksh'
export text3='log_file\=\$LOG_PATH\$\{UNISON_JOB\}\"\.log\"'
echo $text1
echo $text2
echo $text3
for file in `grep -il ${text1} SANDEEP`
...
I'm dealing with a buggy server that will sometimes fail to accept() connections (but leaves its listening socket open). This is on Linux with unix domain sockets.
Currently the only way to detect this is that after sending a bunch of data, the buffer fills up and blocks, and the server isn't sending any replies. This long-after-the-fac...
On a quite ancient UNIX (Apple A/UX 3.0.1 for 680x0 processors) using the built-in c compiler (cc), this issue arrises.
Here is the code I'm trying to compile:
#include <stdlib.h>
#include <stdio.h>
int main()
int argc;
char **argv;
{
if (argc > 1)
puts(argv[1]);
return (EXIT_SUCCESS);
}
And here is the o...
Hi,
FOund the following on: http://mike.murraynet.net/2009/08/23/parsing-the-verisign-zone-file-with-os-x/
Can unix-masters have a look at it and see if its the best possible way to gather the unique domainsnames in a zone file?
For .NET domains:
grep “^[a-zA-Z0-9-]+ NS .” net.zone|sed “s/NS .//”|uniq >> netdomains.txt
For .COM domai...