10-16-2019
I think you misuse shell variables and the command line. Try to use a file or a pipe instead, from the very beginning!
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
I have a C program that takes anywhere from 5 to 100 arguments and I'd like to run it from a script that makes sure it doesnt take too long to execute. If the C program takes more than 5 seconds to execute, i would like the shell script to kill it and return a short message to the user. ... (3 Replies)
Discussion started by: WeezelDs
3 Replies
2. Shell Programming and Scripting
Hi all,
I wrote this shell script to validate filed numbers for input file. But it take forever to complete validation on a file. The average speed is like 9mins/MB.
Can anyone tell me how to improve the performance of a shell script?
Thanks (12 Replies)
Discussion started by: ozzman
12 Replies
3. UNIX for Dummies Questions & Answers
Hello,
like the title says, how can i measure the time it takes to load a module in Linux, and how how can i measure the time it takes to load a statically compiled module.
/Best Regards Olle
---------- Post updated at 01:13 PM ---------- Previous update was at 11:54 AM ----------
For... (0 Replies)
Discussion started by: ollebanan
0 Replies
4. Shell Programming and Scripting
Dear experts
I have a 200MG text file in this format:
text \tab number
I try to sort using options -fd and it takes very long! is that normal or I can speed it up in some ways?
I dont want to split the file since this one is already splitted.
I use this command: sort -fd file >... (12 Replies)
Discussion started by: voolek
12 Replies
5. UNIX and Linux Applications
Hi,
we currently having a issue where when we send jobs to the server for the application lawson, it is taking a very long time to complete. here are the last few lines of the database log.
2012-09-18-10.35.55.707279-240 E244403536A576 LEVEL: Warning
PID : 950492 ... (1 Reply)
Discussion started by: techy1
1 Replies
6. Shell Programming and Scripting
Hi,
I wish to check the return value for wget $url.
However, some urls are designed to take 45 minutes or more to return.
All i need to check if the URL can be reached or not using wget.
How can i get wget to return the value in a few seconds ? (8 Replies)
Discussion started by: mohtashims
8 Replies
7. UNIX for Advanced & Expert Users
Hi,
Below is my find command
find /opt/app/websphere -name myfolder -perm -600 | wc -l
At time it even takes 20 mins to complete.
my OS is : SunOS mypc 5.10 Generic_150400-09 sun4v sparc SUNW,T5440 (10 Replies)
Discussion started by: mohtashims
10 Replies
8. Shell Programming and Scripting
Hi,
I am trying to search for a Directory called "mont" under a directory path "/opt/app/var/dumps"
Although "mont" is in the very parent directory called "dumps" i.e "/opt/app/var/dumps/mont" and it can never be inside any Sub-Directory of "dumps"; my below find command which also checks... (5 Replies)
Discussion started by: mohtashims
5 Replies
9. Shell Programming and Scripting
Hi,
I have a lengthy script which i have trimmed down for a test case as below.
more run.sh
#!/bin/bash
paths="allpath.txt"
while IFS= read -r loc
do
echo "Working on $loc"
startdir=$loc
find "$startdir" -type f \( ! -name "*.log*" ! -name "*.class*" \) -print |
while read file
do... (8 Replies)
Discussion started by: mohtashims
8 Replies
10. UNIX for Beginners Questions & Answers
Good evening.
because the folder has thousand of files it takes too long and have some trouble to get the largest files and then compress files or delete it, for instance
find . -size +10000000c -exec ls -ld {} \; |sort -k5n | grep -v .gz
The above commad took an hour and i have to cancel... (10 Replies)
Discussion started by: alexcol
10 Replies
POPEN(3) BSD Library Functions Manual POPEN(3)
NAME
pclose, popen -- process I/O
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <stdio.h>
FILE *
popen(const char *command, const char *mode);
int
pclose(FILE *stream);
DESCRIPTION
The popen() function ``opens'' a process by creating a bidirectional pipe, forking, and invoking the shell. Any streams opened by previous
popen() calls in the parent process are closed in the new child process. Historically, popen() was implemented with a unidirectional pipe;
hence, many implementations of popen() only allow the mode argument to specify reading or writing, not both. Because popen() is now imple-
mented using a bidirectional pipe, the mode argument may request a bidirectional data flow. The mode argument is a pointer to a null-termi-
nated string which must be 'r' for reading, 'w' for writing, or 'r+' for reading and writing.
The command argument is a pointer to a null-terminated string containing a shell command line. This command is passed to /bin/sh, using the
-c flag; interpretation, if any, is performed by the shell.
The return value from popen() is a normal standard I/O stream in all respects, save that it must be closed with pclose() rather than
fclose(). Writing to such a stream writes to the standard input of the command; the command's standard output is the same as that of the
process that called popen(), unless this is altered by the command itself. Conversely, reading from a ``popened'' stream reads the command's
standard output, and the command's standard input is the same as that of the process that called popen().
Note that output popen() streams are fully buffered, by default.
The pclose() function waits for the associated process to terminate; it returns the exit status of the command, as returned by wait4(2).
RETURN VALUES
The popen() function returns NULL if the fork(2) or pipe(2) calls fail, or if it cannot allocate memory.
The pclose() function returns -1 if stream is not associated with a ``popened'' command, if stream already ``pclosed'', or if wait4(2)
returns an error.
ERRORS
The popen() function does not reliably set errno.
SEE ALSO
sh(1), fork(2), pipe(2), wait4(2), fclose(3), fflush(3), fopen(3), stdio(3), system(3)
BUGS
Since the standard input of a command opened for reading shares its seek offset with the process that called popen(), if the original process
has done a buffered read, the command's input position may not be as expected. Similarly, the output from a command opened for writing may
become intermingled with that of the original process. The latter can be avoided by calling fflush(3) before popen().
Failure to execute the shell is indistinguishable from the shell's failure to execute command, or an immediate exit of the command. The only
hint is an exit status of 127.
The popen() function always calls sh(1), never calls csh(1).
HISTORY
A popen() and a pclose() function appeared in Version 7 AT&T UNIX.
Bidirectional functionality was added in FreeBSD 2.2.6.
BSD
May 3, 1995 BSD