Sponsored Content
Top Forums Shell Programming and Scripting redirect frintf to a variable Post 302559638 by vgersh99 on Tuesday 27th of September 2011 06:36:42 PM
Old 09-27-2011
I don't follow your explanation, but...
Code:
#!/bin/bash
free -m | awk '/^Mem:/ { f+=$4; u+=$3 } END {t=f+u; printf("FREEPER: %3.2f\n USEDPER: %3.2f\n", f/t*100, u/t*100)}'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

please help: how to redirect input into a variable

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

Redirect from Variable to command line??

The following creates a needed awk command from some preexisting variables and stores it in the variable i. I then redirect it to a new file change the permission on the file and run it as a script. How can I do a simple redirect on this variable to the command line, instead of creating a new... (8 Replies)
Discussion started by: ugh
8 Replies

3. UNIX for Dummies Questions & Answers

Redirect Output In Variable

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

4. UNIX for Dummies Questions & Answers

Redirect to variable

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

5. Shell Programming and Scripting

after grep i want to redirect it to some variable

for the below grep -i $1 "${logdir}"* | grep -i adding | grep -iv equation | tail -1 | cut -d ':' -f 1 the result of the grep i want to redirect into some variable, i tried to do veri=grep -i $1 "${logdir}"* | grep -i adding | grep -iv equation | tail -1 | cut -d ':' -f 1 but it is... (2 Replies)
Discussion started by: mail2sant
2 Replies

6. Shell Programming and Scripting

redirect variable to same program at next loop

Hi all, I don't know how to redirect a variable in this case: while true do ./ready_data ... done ready_data should read a file looking for an ID, if this doesn't exist then add the last ID seen into the first line. When ID exists there is no problem, but when ID doesn't... (0 Replies)
Discussion started by: csecnarf
0 Replies

7. Shell Programming and Scripting

redirect cat to variable

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

8. UNIX for Dummies Questions & Answers

Redirect Query o/p to variable

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

9. UNIX for Dummies Questions & Answers

Redirect to a Variable? Or is it cmd cap?

Hi, Im reading an ANSI text file and greping for a pattern. Then i cut what i dont need from that pattern. So now i just have what i need. What i have now just so happens to be a constant integer. How can i save this integer in a varaible? Or do i use command capture in some form? cat... (2 Replies)
Discussion started by: oxoxo
2 Replies

10. Shell Programming and Scripting

Redirect Variable Value to a File

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
CGI::Application::Plugin::Redirect(3pm) 		User Contributed Perl Documentation		   CGI::Application::Plugin::Redirect(3pm)

NAME
CGI::Application::Plugin::Redirect - Easy external redirects in CGI::Application SYNOPSIS
package My::App; use CGI::Application::Plugin::Redirect; sub cgiapp_prerun { my $self = shift; if ( << not logged in >> ) { return $self->redirect('login.html'); } } sub byebye { my $self = shift; return $self->redirect('http://www.example.com/', '301 Moved Permanently'); } DESCRIPTION
This plugin provides an easy way to do external redirects in CGI::Application. You don't have to worry about setting headers or worrying about return types, as that is all handled for you. "redirect" does an external redirect, which means that the browser will receive a command to load a new page, and a fresh request will come in. If you just want to display the results of another runmode within the same module, then it is often sufficient to use the "forward" method in CGI::Application::Plugin::Forward instead. METHODS
redirect($url, $status) Interupt the current request, and redirect to an external URL. If you happen to be inside a prerun method when you call this, the current runmode will automatically be short circuited so that it will not execute. As soon as all prerun method have finished, the redirect will happen without the runmode being executed. The $status parameter is optional as the CGI module will default to something suitable. return $self->redirect('http://www.example.com/'); - or - return $self->redirect('http://www.example.com/', '301 Moved Permanently'); SEE ALSO
CGI::Application, CGI::Application::Plugin::Forward, perl(1) AUTHOR
Cees Hek <ceeshek@gmail.com> LICENCE AND COPYRIGHT
Copyright (c) 2005, Cees Hek. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED ORIMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSESSUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. perl v5.12.3 2011-06-25 CGI::Application::Plugin::Redirect(3pm)
All times are GMT -4. The time now is 06:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy