Sponsored Content
Full Discussion: optargs processing
Top Forums Shell Programming and Scripting optargs processing Post 302407980 by kshji on Saturday 27th of March 2010 12:07:38 PM
Old 03-27-2010
Without optargs, "raw" method:
Code:
#!/bin/ksh or bash or dash or ...
#procinfo -r tmpfile -c "cat tmpfile"
ropt=""
copt=""
while [ $# -gt 0 ]
do
        opt="$1"
        case "$opt" in
             -r|--roption) ropt="$2" ; shift ;;
             -c|--coption) copt="$2" ; shift ;;
             --) shift; break ;; # no more options
             -*) echo "usage:$0 ....." >&2  ; exit 1 ;;
             *) break;; # not option, rest line is argument(s)
         esac
         shift
done

But if you like procinfo -r tmpfile sh -c "ls some" -c is not option, then syntax must be
procinfo -r tmpfile "ls -al"
or
procinfo -r tmpfile -- "ls -al"
or
procinfo -r tmpfile -- ls -al

for previous generic template.
-- is "standard" option which tell that no more option, the rest of line is arguments.
Code:
...
done
data="$@"
echo "$data"
# do it
$data

 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Optargs????

Hi I am sorry if my query is too simple ...... Can anybody explain the usage of optargs in shell script with options having arguments associated with them. Thanks in advance !!! (8 Replies)
Discussion started by: skyineyes
8 Replies

2. Shell Programming and Scripting

help with processing a file

I have a file with header and data rows. I need to remove the header rows from the file and use the data rows for my processing. The problem is the header is not always constant number of rows. But the only way to identify the last row of the header is that it has the header information of... (4 Replies)
Discussion started by: dsravan
4 Replies

3. Shell Programming and Scripting

How to make parallel processing rather than serial processing ??

Hello everybody, I have a little problem with one of my program. I made a plugin for collectd (a stats collector for my servers) but I have a problem to make it run in parallel. My program gathers stats from logs, so it needs to run in background waiting for any new lines added in the log... (0 Replies)
Discussion started by: Samb95
0 Replies

4. Shell Programming and Scripting

File processing

bash-2.05$ vi file_read.sh "file_read.sh" 9 lines, 97 characters #!/bin/ksh print "Enter the group name" read gname varA= grep "$gname::" group print $varA This is the scenario: I am trying to get a userid and groupname from user and trying to add the userid to the given group.... (11 Replies)
Discussion started by: mnathan
11 Replies

5. IP Networking

Processing time

I want to know the processing time taken by a node.example suppose a node ges a rreq...then it searched through it's table to see if it has a fresh route or not.I want to know this search time...is their any function available for doing this in ns2 or in glomosim.Any help is highly appreciated ... (1 Reply)
Discussion started by: prashantgolu
1 Replies

6. Programming

awk processing / Shell Script Processing to remove columns text file

Hello, I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this : This is the output of ls command : I stored the output in a file filelist 1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies

7. Shell Programming and Scripting

File processing

Hi, I have a file 2013-01-01 2013-01-02 01-03-2013 03-03-2013 mar05 I need all the dates YYYY-MM-DD in a separate file and rest of the things in different file. File 1: 2013-01-01 2013-01-02 File 2: (8 Replies)
Discussion started by: ATWC
8 Replies
tmpfile(3)						     Library Functions Manual							tmpfile(3)

NAME
tmpfile - Creates a temporary file LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <stdio.h> FILE *tmpfile ( void ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: tmpfile(): XSH4.2 Refer to the standards(5) reference page for more information about industry standards and associated tags. DESCRIPTION
The tmpfile() function creates a temporary file and returns its FILE pointer. The file is opened for update. The temporary file is automat- ically deleted when the process using it terminates. RETURN VALUES
Upon successful completion, the tmpfile() function returns a pointer to the stream of the file that is created. Otherwise, it returns a null pointer and sets errno to indicate the error. ERRORS
The tmpfile() function sets errno to the specified values for the following conditions: A signal was caught during tmpfile(). OPEN_MAX file descriptors are currently open in the calling process. [Tru64 UNIX] All available file descriptors are currently open in the calling process. The maximum allowable number of files is currently open in the system. The directory or file system that would contain the new file cannot be expanded. RELATED INFORMATION
Functions: fopen(3), mktemp(3), tmpnam(3), unlink(2), getdtablesize(2) Standards: standards(5) delim off tmpfile(3)
All times are GMT -4. The time now is 04:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy