Sponsored Content
Top Forums Shell Programming and Scripting Passing variables problem - Bash Post 302499348 by bobanpetrovic on Thursday 24th of February 2011 06:56:53 AM
Old 02-24-2011
Passing variables problem - Bash

I have a following problem:
Code:
#!/bin/bash
NUM=`cat accounts | wc -l`; 
for i in {1..$NUM}
do
    account=`awk "NR==$i" accounts`;
    echo -e "\nAccount: $account\n";
    sudo ./backup_maildir $account;
done

"accounts" is a file with regular e-mail addresses, one in each line.
backup_maildir is expect script.

When the main script is executed, the 6th line successfuly echo current mail address, but the following line is not passing that string to backup_maildir script. If the $account variable is user@domain.com, a string that is passed to backup_maildir is {user@domain.com?} ?! How is that possible? How to solve it?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing variable from bash to perl from bash script

Hi All, I need to pass a variable to perl script from bash script, where in perl i am using if condition. Here is the cmd what i am using in perl FROM_DATE="06/05/2008" TO_DATE="07/05/2008" "perl -ne ' print if ( $_ >="$FROM_DATE" && $_ <= "$TO_DATE" ) ' filename" filename has... (10 Replies)
Discussion started by: arsidh
10 Replies

2. Shell Programming and Scripting

Passing 2 variables

Hi All, I need to pass 2 variables name 'vamskt' and 'vamsi'. Here is my question: delete from gpi.usergroup where usg_user_id in ('vamskt'); delete from gpi.userroles where uro_user_id in ('vamskt'); delete from gpi.user where usr_id in ('vamskt'); insert into gpi.user... (3 Replies)
Discussion started by: tvamsikiran
3 Replies

3. Shell Programming and Scripting

problem using variables in bash script

I am using variable to give the location of the file I am using but I get error. Here is the code: LogFile=/tmp/log.email echo -e "could not close the service - error number $error \n" > $LogFile well this is not all the code but is enough because the problem start when I try to use the... (3 Replies)
Discussion started by: programAngel
3 Replies

4. Shell Programming and Scripting

Passing variables from bash to php-cli

Hello everyone, I've been looking how to pass variables between bash and php-cli in 1 file. So far i got this: #!/bin/bash echo "This is bash" php << EOF <?php echo "This is php\n"; ?> EOF I would now like to be able to pass a variable declared in the bash to the php. I already... (0 Replies)
Discussion started by: robbee
0 Replies

5. Shell Programming and Scripting

Problem with positional variables in BASH

Hello, my problem is simple & I searched a lot but I couldn't find anything about it: Basically I'd like to pass $i to a variable, $i being the positional variable; but it is unknown in the beginning so I can't do it like eg. myvar=$3, it HAS to be the "i".. First, I tried myvar=$($i) ... (8 Replies)
Discussion started by: timmyyyyy
8 Replies

6. Shell Programming and Scripting

Passing Variables

I have below data: DAY1=10202013 I am trying below but not getting the desired output: COUNT=1 DATE=DAY$COUNT echo "Date is $DATE" However output I am getting is: Date is DAY1 I wanted the output as: Date is 10202013 I tried following as well: DAY1=10202013 COUNT=1... (3 Replies)
Discussion started by: rockyr1985
3 Replies

7. Shell Programming and Scripting

Problem with variables and bash script

From the command line: dions-air:scripts dion$ ls -l /Users/dion/Library/Application\ Support/Garmin/Devices/3816821036/History/2014-06-07-055251.TCX -rw-r--r-- 1 dion staff 157934 7 Jun 06:55 /Users/dion/Library/Application Support/Garmin/Devices/3816821036/History/2014-06-07-055251.TCXworks... (2 Replies)
Discussion started by: dionbl
2 Replies

8. Shell Programming and Scripting

Passing awk variables to bash variables

Trying to do so echo "111:222:333" |awk -F: '{system("export TESTO=" $2)}'But it doesn't work (2 Replies)
Discussion started by: urello
2 Replies

9. Shell Programming and Scripting

[BASH] Getting a semi-tailing backslash when passing (escaped) variables to script

Heyas Figured me had a 'typo' in tui-conf-set, i went to fix it. Now, i also figured, it might be nice to have tui-conf-set report (to console, not only exit code) wether it could save the variable to the file or not. This said, I appended this code: (the tui-title and tui-echo lines are... (3 Replies)
Discussion started by: sea
3 Replies

10. Shell Programming and Scripting

[Bash] passing variables to executable doesn't work

Bash version 4.4.20 / Ubuntu 16.0.4 Hello, I tried to write a script that gathers some data and passes them to an executable. The executed application answers with an error. The echo output in the script returns correct values. If I copy/paste the last echo command, it get's executed... (2 Replies)
Discussion started by: sushi2k7
2 Replies
RG::Blast::Parser(3pm)					User Contributed Perl Documentation				    RG::Blast::Parser(3pm)

NAME
RG::Blast::Parser - fast NCBI BLAST parser SYNOPSIS
use Data::Dumper; use RG::Blast::Parser; my $parser = RG::Blast::Parser->new(); # read from STDIN open( EXAMPLE, '<', '/usr/share/doc/librg-blast-parser-perl/examples/converged.ali' ) || confess($!); my $parser = RG::Blast::Parser->new( *EXAMPLE, "converged.ali" ); # read from EXAMPLE, use name "converged.ali" in error messages while( my $res = $parser->parse() ) { print Dumper( $res ); } eval { my $res = $parser->parse(); # ... }; if( $@ && $@ =~ /^parser error/ ) { warn("failed to parse blast result - exception caught"); } DESCRIPTION
This package contains perl binding for a very fast C/C++ library for NCBI BLAST -m 0 (default) output parsing. BLAST results are returned in a convenient hash structure. Multiple results may be concatenated for input. One result is parsed and returned at a time. CONSTRUCTOR
new( [FILEHANDLE, [NAME]] ) Creates an "RG::Blast::Parser". Blast results are read from FILEHANDLE, STDIN by default. The input stream may be named NAME in error messages (default: "STDIN"). METHODS
parse( [TRACE_PARSING, [TRACE_SCANNING]] ) Parse one complete BLAST result and return it. If no results on input stream, returns "undef". In case of parser error it die()s with an (at present not very useful) error message. The following structure is returned in a hash reference: { blast_version => STRING, references => [ STRING, ... ], rounds => [ { oneline_idx => NUM, # index of first one-line description of # round in "onelines" oneline_cnt => NUM, # number of one-line descriptions of round # in "onelines" hit_idx => NUM, # index of first hit of round in "hits" hit_cnt => NUM, # number of hits of round in "hits" oneline_new_idx => NUM|undef# index of first new (not-seen-before) # one-line description of round oneline_new_cnt => NUM # number of new one-line descriptions of # round }, ... ], q_name => STRING, q_desc => STRING|undef, q_length => NUM, db_name => STRING, db_nseq => NUM, db_nletter => NUM, onelines => [ # one-line descriptions from all rounds { name => STRING, desc => STRING|undef, bit_score => NUM, e_value => NUM }, ... ], converged => BOOLEAN, hits => [ # hits from all rounds { name => STRING, desc => STRING|undef, length => NUM, hsps => [ { bit_score => NUM, raw_score => NUM, e_value => NUM, method => STRING, identities => NUM, positives => NUM, gaps => NUM, q_strand => STRING|undef, s_strand => STRING|undef, q_frame => NUM|undef, s_frame => NUM|undef, q_start => NUM, q_ali => STRING, q_end => NUM, match_line => STRING, s_start => NUM, s_ali => STRING, s_end => NUM }, ... ] }, ... ], tail => STRING # bulk text after the last hit / one-line # description } If you want tracing for parsing and scanning, you can enable them using the parameters of this call. result() Returns the last BLAST result parsed or "undef" if no last result. get_trace_scanning() Returns scan trace state as a Boolean value. set_trace_scanning( BOOLEAN ) Set scan trace - debugging aid. SEE ALSO
Zerg(3pm), Zerg::Report(3pm) AUTHOR
Laszlo Kajan, <lkajan@rostlab.org> COPYRIGHT AND LICENSE
Copyright (C) 2012 by Laszlo Kajan This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. perl v5.14.2 2012-03-29 RG::Blast::Parser(3pm)
All times are GMT -4. The time now is 02:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy