04-07-2008
vari=$(your_command_here)
or
vari=`your_command_here`
second example uses backticks, google it to learn more.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I'm trying to write a simple script program (C shell). I have a problem redirecting input into a variable. Say I have a variable called J, and there is file called result which contains just some number, say 5. Which command should I use to assign J value 5 from the file result. I tried the... (2 Replies)
Discussion started by: artur80
2 Replies
2. UNIX for Dummies Questions & Answers
how make assign the output of the command (for example: grep "file" "string" ) in a variable ($name)?
i thing how put the result of the command (grep , cut, find ecc) in a variable..
IT's Possible ?? (1 Reply)
Discussion started by: ZINGARO
1 Replies
3. UNIX for Dummies Questions & Answers
how do you redirect stdout into a variable. whenever I try I get an ambiguous redirect error :( I am trying to validate some user input and failing miserably.
cal $MONTH $YEAR | grep -c "$DAY"
if the above is 1 then it is valid if 0 then not valid. I have been trying to redirect the output... (2 Replies)
Discussion started by: MrAd
2 Replies
4. Shell Programming and Scripting
i want to redirect the grep output into the variable
but i am not able to get it
i tried
veri=`grep -i $1 "${logdir}"* | grep -i adding | grep -iv equation | tail -1 | cut -d ':' -f 1`
vari=$(grep -i $1 "${logdir}"* | grep -i adding | grep -iv equation | tail -1 | cut -d ':' -f 1)
BUT NOT... (1 Reply)
Discussion started by: mail2sant
1 Replies
5. Shell Programming and Scripting
Hi,
I am writing the following code in command prompt it is working fine.
grep ',222,' SAPPCO_20080306.CSV_old > SAPPCO_20080306.CSV_new
But the command is not working in the Shell Script...
##########################################
#!/bin/sh
#... (2 Replies)
Discussion started by: hanu_oracle
2 Replies
6. Shell Programming and Scripting
hello
just i saw a really strange for cat
i have file (file1) contains line /home/rajiv/proj1/*.txt
now applied a commonds
DDPATH="$(cat file1)"
echo $DDPATH
it shows all the txt files in that folder like /home/rajiv/proj1/read1.txt /home/rajiv/proj1/read2.txt... (7 Replies)
Discussion started by: shailesh_arya
7 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I wanted to o/p the number of rows in a table to a variable in linux. How can i achieve this.
I wrote the query and its settings like feedback, pagesize line size in a file and using this file as a parameter to the sqlplus command. now can i redirect the o/p of that query to a variable.... (2 Replies)
Discussion started by: Swapna173
2 Replies
8. UNIX for Dummies Questions & Answers
How can I send the results of a query to a unix variable. I basically want to run a query then do some logic on the results. Trying to redirect the result into a variable I define in the script.
select count(*) as counter from table - nut to redirect the "count" returned from the query... (2 Replies)
Discussion started by: rstone
2 Replies
9. Shell Programming and Scripting
how to redirect printf to a variable (8 Replies)
Discussion started by: robo
8 Replies
10. Shell Programming and Scripting
I have shell script generate.sh that has
var="HP-UX"
I am following example 19-8 in the below document.
Here Documents
The output.txt is generated however I want the value of variable var to be reflected in the contents of the output.txt file
cat <<'EOF' #!/bin/bash
connect("Welcome... (1 Reply)
Discussion started by: mohtashims
1 Replies
LEARN ABOUT DEBIAN
net::oauth::client
Net::OAuth::Client(3pm) User Contributed Perl Documentation Net::OAuth::Client(3pm)
NAME
Net::OAuth::Client - OAuth 1.0A Client
SYNOPSIS
# Web Server Example (Dancer)
# This example is simplified for illustrative purposes, see the complete code in /demo
# Note that client_id is the Consumer Key and client_secret is the Consumer Secret
use Dancer;
use Net::OAuth::Client;
sub client {
Net::OAuth::Client->new(
config->{client_id},
config->{client_secret},
site => 'https://www.google.com/',
request_token_path => '/accounts/OAuthGetRequestToken?scope=https%3A%2F%2Fwww.google.com%2Fm8%2Ffeeds%2F',
authorize_path => '/accounts/OAuthAuthorizeToken',
access_token_path => '/accounts/OAuthGetAccessToken',
callback => uri_for("/auth/google/callback"),
session => &session,
);
}
# Send user to authorize with service provider
get '/auth/google' => sub {
redirect client->authorize_url;
};
# User has returned with token and verifier appended to the URL.
get '/auth/google/callback' => sub {
# Use the auth code to fetch the access token
my $access_token = client->get_access_token(params->{oauth_token}, params->{oauth_verifier});
# Use the access token to fetch a protected resource
my $response = $access_token->get('/m8/feeds/contacts/default/full');
# Do something with said resource...
if ($response->is_success) {
return "Yay, it worked: " . $response->decoded_content;
}
else {
return "Error: " . $response->status_line;
}
};
dance;
DESCRIPTION
Net::OAuth::Client represents an OAuth client or consumer.
WARNING: Net::OAuth::Client is alpha code. The rest of Net::OAuth is quite stable but this particular module is new, and is under-
documented and under-tested.
METHODS
new($client_id, $client_secret, %params)
Create a new Client
o $client_id
AKA Consumer Key - you get this from the service provider when you register your application.
o $client_secret
AKA Consumer Secret - you get this from the service provider when you register your application.
o $params{site}
o $params{request_token_path}
o $params{authorize_path}
o $params{access_token_path}
o $params{callback}
o $params{session}
LICENSE AND COPYRIGHT
Copyright 2011 Keith Grennan.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as
published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
perl v5.14.2 2012-01-10 Net::OAuth::Client(3pm)