Sponsored Content
Top Forums Shell Programming and Scripting Change existing variable value only user enters non-empty string. Post 302422938 by fpmurphy on Wednesday 19th of May 2010 08:13:22 PM
Old 05-19-2010
Quote:
Can someone explain what are true differences between -z, -n flags !!? Where can I find true reference for this?
Just experiment. For example, the following will also work in your script
Code:
if [  -n "${resp}" ]; then

An even better way is to use [[ ]] as in
Code:
if [[  -n "${resp}" ]]; then

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

if test for empty and non-existing file

How to write this condition in ksh? if myfile is empty or myfile does not exist then do action1 fi is this OK? if ] -o ] then then do action1 fi Thanks. (3 Replies)
Discussion started by: GNMIKE
3 Replies

2. UNIX for Dummies Questions & Answers

how can i change the date of an existing file

Hi, Plz suggest me how can i change the date of a file. Suppose my file has been created in some date and i want to give it present date. How can i do this???? (2 Replies)
Discussion started by: adityam
2 Replies

3. UNIX for Dummies Questions & Answers

New Variable with Existing variable( Urgent)

hi all, i want use the variable value as a new variable name. print output of new variable. for i in COMPUTER1 COMPUTER2 do flag_name=${i}_FLAG eval ${flag_name}=123 echo $i'_FLAG' done output is COMPUTER1_FLAG COMPUTER2_FLAG i need output as 123 123 (2 Replies)
Discussion started by: arvindng
2 Replies

4. Solaris

Add existing user into an existing group

Pre: no gpasswd/adduser there is just usermod can be used, also there is no -a option for usermod. How should I add a user into a group? (4 Replies)
Discussion started by: a2156z
4 Replies

5. Shell Programming and Scripting

BASH - set specific user variable via string operators

Apologies for the utter triviality of this question, but we all have to start somewhere! I've also tried searching but this question is pretty vague so I didn't (a) really know what to search for or (b) get many relevant hits to what I did search for. Anyway, I'm in the process of self-teaching... (1 Reply)
Discussion started by: u5j84
1 Replies

6. Shell Programming and Scripting

awk: change string variable

Hi. How to change string variable in awk? for example, I parse with awk script text file named some_name_with_extension.txt I want to print only some_name in my script .... varCompName = FILENAME print varCompName How to put not all symbols from FILENAME to variable? thank you This... (4 Replies)
Discussion started by: cintlt
4 Replies

7. Shell Programming and Scripting

How to change last character in string with a variable value.

Hey Guys, I have text such as this. 28003,ALCORN,2 28009,BENTON,2 28013,CALHOUN,2 28017,CHICKASAW,2 47017,CARROLL,2 05021,CLAY,0 The last digit after the final "," is a variable value. This is the base file. I have to do further execution on this file later and I need to update the... (7 Replies)
Discussion started by: chagan02
7 Replies

8. Shell Programming and Scripting

How do I change a variable to something only if it's empty?

I feel like it is just a matter of using the $ operators correctly, but I can't seem to get it... hostname="network" ip="192.168.1.1" netmask="" variables=( $hostname $ip $netmask ) for var in ${variables} do if ; then $var="--" fi done echo... (7 Replies)
Discussion started by: etranman1
7 Replies

9. Shell Programming and Scripting

Script stops running after assigning empty string for a variable

Hi, This is the first time I see something like this, and I don't why it happens. Please give me some help. I am really appreciate it. Basically I am trying to remove all empty lines of an input.. #!/bin/bash set -e set -x str1=`echo -e "\nhaha" | grep -v ^$` #str2=`echo -e "\n" |... (4 Replies)
Discussion started by: yoyomano
4 Replies

10. Shell Programming and Scripting

Change date time stamp of existing file

I have a file hello.txt which was created today (today's date timestamp) I wish to change its date timestamp (access, modified, created) to 1 week old i.e one week from now. uname -a SunOS mymac 5.11 11.2 sun4v sparc sun4v Can you please suggest a easy way to do that ? (12 Replies)
Discussion started by: mohtashims
12 Replies
WebKDC(3pm)						User Contributed Perl Documentation					       WebKDC(3pm)

NAME
WebKDC - functions to support the WebKDC SYNOPSIS
use WebAuth; use WebKDC; use WebKDC::Exception; use WebKDC::WebRequest; use WebKDC::WebResponse; my ($status, $exception) = WebKDC::make_request_token_request($req, $resp); DESCRIPTION
WebKDC is a set of convenience functions built on top of mod WebAuth to implement the WebKDC. All functions have the potential to throw either a WebKDC::WebKDCException or WebAuth::Exception. EXPORT
None FUNCTIONS
make_request_token_request(req,resp) ($status, $e) = WebKDC::make_request_token_request($req, $resp); Used to handle an incoming request token. It should be used in the following fashion: my $req = new WebKDC::WebRequest; my $resp = new WebKDC::WebResponse; # if the user just submitted their username/password, include them if ($username && $password) { $req->user($username); $req->pass($password); } # pass in any proxy-tokens we have from a cookies # i.e., enumerate through all cookies that start with webauth_wpt # and put them into a hash: # $cookies = { "webauth_wpt_krb5" => $cookie_value } $req->proxy_cookies($cookies); # $req_token_str and $service_token_str would normally get # passed in via query/post parameters $req->request_token($req_token_str); $req->service_token($service_token_str); my ($status, $e) = WebKDC::make_request_token_request($req, $resp); # for all these cases, check if $resp->proxy_cookies() has any # proxy cookies we need to update when sending back a page to # the browser if ($status == WK_SUCCESS) { # ok, request successful } elsif ($status == WK_ERR_USER_AND_PASS_REQUIRED || $status == WK_LOGIN_FORCED) { # prompt for user/pass } elsif ($status == WK_ERR_LOGIN_FAILED) { # supplied user/pass was invalid, try again } else { # use this if/elsif/else to pick the error message if ($status == WK_ERR_UNRECOVERABLE_ERROR) { # something nasty happened. } elsif ($status == WK_ERR_REQUEST_TOKEN_STATLE) { # user took too long to login, original request token is stale } elsif ($status == WK_ERR_WEBAUTH_SERVER_ERROR) { # like WK_ERR_UNRECOVERABLE_ERROR, but indicates the error # most likely is due to the webauth server making the request, } else { # treat like WK_ERROR_UNRECOVERABLE ERROR } # display the error message and don't prompt anymore } AUTHOR
Roland Schemers (schemers@stanford.edu) SEE ALSO
WebKDC::WebKDCException WebKDC::Token WebKDC::WebRequest WebKDC::WebRespsonse WebAuth. perl v5.14.2 2012-04-25 WebKDC(3pm)
All times are GMT -4. The time now is 07:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy