Sponsored Content
Full Discussion: Checking commandline
Top Forums Shell Programming and Scripting Checking commandline Post 302761305 by vbe on Friday 25th of January 2013 12:08:26 PM
Old 01-25-2013
This has nothing to do here where we expect to see code issues...
Is this homework?
Till you give a clear answer this thread is closed

Last edited by vbe; 01-26-2013 at 08:45 AM.. Reason: typos
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

list only directories in commandline.

I want to list only directories in the command line using ls command. Can anyone please help me. (9 Replies)
Discussion started by: jhmr7
9 Replies

2. Shell Programming and Scripting

Validating commandline argument

Hi, I am calling a script script2.shl from script1.shl as below script2.shl "TABLE_NAME" -r 10 In that I have to validate the parameter 4. i.e : it should be only 10 20 30 40 50 I know that I can do it by checking like below if ]; then echo "TRUE" else echo "FALSE" fi ... (3 Replies)
Discussion started by: mr_manii
3 Replies

3. Shell Programming and Scripting

$OPTARG changes commandline input

Hi there, I hope, that I do not open an thread, that is already existing, but I didn't found something matching with my problem while searching for problems with "getopts" My problem ist, that I'm taking arguments from commandline into my script with getopts, I've an flag -s, after that there... (2 Replies)
Discussion started by: thommes_pommes
2 Replies

4. Shell Programming and Scripting

Using curl in commandline

Hi, I am using curl to hit a url using http in solaris 10 using commandline, I want to transfer an attachment(using multipart curl -F) also as a part of the request. If anyone has used kindly help me with the syntax. I am using below command: /usr/local/bin/curl -v... (1 Reply)
Discussion started by: manishmaha
1 Replies

5. Shell Programming and Scripting

Multiple commandline switches

I have a script that has commandline switches that work no problem. But i don't know how to enable it to have multiple switches at one time. So I'd want myscript -h -o or even myscript -ho but i'm having no luck incorporating this. I tried shifting but i'm not getting it. Thanks ----------... (0 Replies)
Discussion started by: DC Slick
0 Replies

6. Shell Programming and Scripting

AWK Script and Commandline difference

Hey there, I just stumbled upon a difference between using awk on the commandline and using it in a shellscript. I have a variable, e.g.: PROG=vim then i want to check if the package with this name is installed: TEMPVAL=$(dpkg -l | awk '{ if ($2 == "$PROG") print $2 }') (Im using... (10 Replies)
Discussion started by: MrSnail
10 Replies

7. OS X (Apple)

Opening Applications from the commandline

as you probably/may know, one can open any application from the application folder with the command open -a program_name I found that out today and so I created aliases in .bash_profile and they work. alias safari="open -a safari" alias gimp="open -a gimp" alias seamonkey="open -a... (0 Replies)
Discussion started by: butterbaerchen
0 Replies

8. UNIX for Dummies Questions & Answers

Load config file at commandline

Hello, This would be very basic question to most of you, but for me as a newbie it is an un-know. I would like to load a configuration file into memory before executing a specific command. For example: I have a config file that holds all the database connectivity information and I'd like to... (5 Replies)
Discussion started by: babyPen1985
5 Replies

9. Shell Programming and Scripting

Script executed by Cron or commandline

Hello all, I have a question regarding the difference betwen cron and command line. What I would like to do is to print a statement into a logfile if a script has been executed from cron or from command line. It should be as: #!/bin/bash if <Check if this script has been... (3 Replies)
Discussion started by: API
3 Replies
UPSCLI_GET(3)							    NUT Manual							     UPSCLI_GET(3)

NAME
upscli_get - retrieve data from a UPS SYNOPSIS
#include <upsclient.h> int upscli_get(UPSCONN_t *ups, int numq, const char **query, int *numa, char ***answer) DESCRIPTION
The upscli_get() function takes the pointer ups to a UPSCONN_t state structure, and the pointer query to an array of numq query elements. It builds a properly-formatted request from those elements and transmits it to upsd(8). Upon success, the response will be split into separate components. A pointer to those components will be returned in answer. The number of usable answer components will be returned in numa. USES
This function implements the "GET" command in the protocol. As a result, you can use it to request many different things from the server. Some examples are: o GET NUMLOGINS <ups> o GET UPSDESC <ups> o GET VAR <ups> <var> o GET TYPE <ups> <var> o GET DESC <ups> <var> o GET CMDDESC <ups> <cmd> QUERY FORMATTING
To generate a request for GET NUMLOGINS su700, you would populate query and numq as follows: int numq; const char *query[2]; query[0] = "NUMLOGINS"; query[1] = "su700"; numq = 2; All escaping of special characters and quoting of elements with spaces is handled for you inside this function. ANSWER FORMATTING
The raw response from upsd to the above query would be NUMLOGINS su700 1. Since this is split up for you, the values work out like this: numa = 3; answer[0] = "NUMLOGINS" answer[1] = "su700" answer[2] = "1" Notice that the value which you seek typically starts at answer[numq]. ERROR CHECKING
This function will check your query against the response from upsd(8). For example, if you send "VAR" "su700" "ups.status", it will expect to see those at the beginning of the response. If the results from upsd do not pass this case-insensitive test against your request, this function will return an error. When this happens, upscli_upserror(3) will return UPSCLI_ERR_PROTOCOL. ANSWER ARRAY LIFETIME
The pointers contained within the answer array are only valid until the next call to a upsclient function which references them. If you need to use data from multiple calls, you must copy it somewhere else first. The answer array and its elements may change locations, so you must not rely on previous addresses. You must only use the addresses which were returned by the most recent call. You also must not attempt to use more than numa elements in answer. Such behavior is undefined, and may yield bogus data or a crash. The array will be deleted after calling upscli_disconnect(3). Any access after that point is also undefined. RETURN VALUE
The upscli_get() function returns 0 on success, or -1 if an error occurs. SEE ALSO
upscli_list_start(3), upscli_list_next(3), upscli_strerror(3), upscli_upserror(3) Network UPS Tools 05/22/2012 UPSCLI_GET(3)
All times are GMT -4. The time now is 08:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy