Sponsored Content
Full Discussion: Save output in a variable
Top Forums Shell Programming and Scripting Save output in a variable Post 302424207 by angshuman_ag on Monday 24th of May 2010 01:39:12 PM
Old 05-24-2010
If I give a bogus option flag like you said, it ignores the option and does the conversion successfully. It just requires the input filename. If provided with other flag like -f or -outdir, it will use them else will ignore other flags.

So, the bogus option flag is ignored and no usage mesages are seen.
 

10 More Discussions You Might Find Interesting

1. AIX

topas -P save output

hi i have server monitor script which totally depends upon the output of TOP which works fine on HP. now i am told to put same script on aix i found that topas -P produces same output but it doesnt redirect output to file i have to kill/terminate it. is there any other way to this. as the... (0 Replies)
Discussion started by: zedex
0 Replies

2. UNIX for Dummies Questions & Answers

Command display output on console and simultaneously save the command and its output

Hi folks, Please advise which command/command line shall I run; 1) to display the command and its output on console 2) simultaneous to save the command and its output on a file I tried tee command as follows; $ ps aux | grep mysql | tee /path/to/output.txt It displayed the... (7 Replies)
Discussion started by: satimis
7 Replies

3. Shell Programming and Scripting

to save output of a command in hash variable

Hi all, is it possible to save the output of a unix command executed in perl to be saved in hash variable.. like i have the command `find $mypath ! -user mainuser -printf \"\%u \%h\\n\"`; this will print all the users other than mainuser with their paths. so is possible to capture... (2 Replies)
Discussion started by: saapa
2 Replies

4. Shell Programming and Scripting

Save cURL verbose output to file or do it like browser "save as.."

hi there ! i have exactly the same problem like this guy here https://www.unix.com/shell-programming-scripting/127668-getting-curl-output-verbose-file.html i am not able to save the curl verbose output.. the sollution in this thread (redirecting stderr to a file) does not work for me.... (0 Replies)
Discussion started by: crabmeat
0 Replies

5. Shell Programming and Scripting

how to save an output of a command in a variable

Hi, in shell script, i have the command swstart -p which returns an output. i want to store the output of this command into a variable. how i can do that excerpt from the script #!/usr/bin/ksh # # # # Program: swstart -p # # Description: Starts the sentinels on Slave server ... (4 Replies)
Discussion started by: lookinginfo
4 Replies

6. Shell Programming and Scripting

how can save output?

I make shell script by use "if" statement, what should add it to shell script save which I enter it in output file txt? ---------- Post updated at 08:27 AM ---------- Previous update was at 05:59 AM ---------- I mean like this echo "enter your name" read name # now i when start... (1 Reply)
Discussion started by: Oman_Member
1 Replies

7. UNIX for Dummies Questions & Answers

Solved: how to save an output to a variable

i want to save the output of /scripts/whoowns domain.com to a username like $user = /scripts/whoowns domain.com but I'm not sure how to do that This is inside a bash script how can I get the output of /scripts/whoowns then save that to a variable? thanks! ---------- Post updated at... (0 Replies)
Discussion started by: vanessafan99
0 Replies

8. Programming

Save output in text C++

Hi , i want to save the output of my c ++ code to a text file which is in a particular path : this is part of my code and I dunno where I am doing it wrong do { for( int i = 0; i < l; ++i ) { std::cout << 1 + k * i + index << ' '; } ... (2 Replies)
Discussion started by: siya@
2 Replies

9. UNIX for Dummies Questions & Answers

I save the result in a variable

I have friends that this command worked perfectly, but I would like to save the result in a variable, which I have not achieved var=prueba.txt echo $var | cut -d "." -f 1 prueba I need to do this but does not work me salida=echo $var | cut -d "." -f 1 echo "result:$salida" ... (8 Replies)
Discussion started by: tricampeon81
8 Replies

10. Shell Programming and Scripting

Save value from output of Corestat and save in a list for each core

I am trying to modify the "corestat v1.1" code which is in Perl.The typical output of this code is below: Core Utilization CoreId %Usr %Sys %Total ------ ----- ----- ------ 5 4.91 0.01 4.92 6 0.06 ... (0 Replies)
Discussion started by: Zam_1234
0 Replies
cmdline(n)						Command line and option processing						cmdline(n)

__________________________________________________________________________________________________________________________________________________

NAME
cmdline - Procedures to process command lines and options. SYNOPSIS
package require Tcl 8.2 package require cmdline ?1.3.1? ::cmdline::getopt argvVar optstring optVar valVar ::cmdline::getKnownOpt argvVar optstring optVar valVar ::cmdline::getoptions arglistVar optlist ?usage? ::cmdline::getKnownOptions arglistVar optlist ?usage? ::cmdline::usage optlist ?usage? ::cmdline::getfiles patterns quiet ::cmdline::getArgv0 _________________________________________________________________ DESCRIPTION
This package provides commands to parse command lines and options. ::cmdline::getopt argvVar optstring optVar valVar This command works in a fashion like the standard C based getopt function. Given an option string and a pointer to an array or args this command will process the first argument and return info on how to proceed. The command returns 1 if an option was found, 0 if no more options were found, and -1 if an error occurred. argvVar contains the name of the list of arguments to process. If options are found the list is modified and the processed arguments are removed from the start of the list. optstring contains a list of command options that the application will accept. If the option ends in ".arg" the command will use the next argument as an argument to the option. Otherwise the option is a boolean that is set to 1 if present. optVar refers to the variable the command will store the found option into (without the leading '-' and without the .arg extension). valVar refers to the variable to store either the value for the specified option into upon success or an error message in the case of failure. The stored value comes from the command line for .arg options, otherwise the value is 1. ::cmdline::getKnownOpt argvVar optstring optVar valVar Like ::cmdline::getopt, but ignores any unknown options in the input. ::cmdline::getoptions arglistVar optlist ?usage? Processes the set of command line options found in the list variable named by arglistVar and fills in defaults for those not speci- fied. This also generates an error message that lists the allowed flags if an incorrect flag is specified. The optional usage-argu- ment contains a string to include in front of the generated message. If not present it defaults to "options:". optlist contains a list of lists where each element specifies an option in the form: flag default comment. If flag ends in ".arg" then the value is taken from the command line. Otherwise it is a boolean and appears in the result if present on the command line. If flag ends in ".secret", it will not be displayed in the usage. ::cmdline::getKnownOptions arglistVar optlist ?usage? Like ::cmdline::getoptions, but ignores any unknown options in the input. ::cmdline::usage optlist ?usage? Generates and returns an error message that lists the allowed flags. optlist is defined as for ::cmdline::getoptions. The optional usage-argument contains a string to include in front of the generated message. If not present it defaults to "options:". ::cmdline::getfiles patterns quiet Given a list of file patterns this command computes the set of valid files. On windows, file globbing is performed on each argu- ment. On Unix, only file existence is tested. If a file argument produces no valid files, a warning is optionally generated (set quiet to true). This code also uses the full path for each file. If not given it prepends the current working directory to the filename. This ensures that these files will never conflict with files in a wrapped zip file. The last sentence refers to the pro-tools. ::cmdline::getArgv0 This command returns the "sanitized" version of argv0. It will strip off the leading path and removes the extension ".bin". The latter is used by the pro-apps because they must be wrapped by a shell script. EXAMPLES
set options { {a "set the atime only"} {m "set the mtime only"} {c "do not create non-existent files"} {r.arg "" "use time from ref_file"} {t.arg -1 "use specified time"} } set usage ": MyCommandName [options] filename ... options:" array set params [::cmdline::getoptions argv $options $usage] if { $params(a) } { set set_atime "true" } set has_t [expr {$params(t) != -1}] set has_r [expr {[string length $params(r)] > 0}] if {$has_t && $has_r} { return -code error "Cannot specify both -r and -t" } elseif {$has_t} { ... } This example, taken (and slightly modified) from the package fileutil, shows how to use cmdline. First, a list of options is created, then the 'args' list is passed to cmdline for processing. Subsequently, different options are checked to see if they have been passed to the script, and what their value is. BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category cmdline of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. KEYWORDS
argument processing, argv, argv0, cmdline processing, command line processing cmdline 1.3.1 cmdline(n)
All times are GMT -4. The time now is 11:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy