Sponsored Content
Top Forums Shell Programming and Scripting passing variable content to a function Post 302574696 by vivek d r on Friday 18th of November 2011 05:15:38 AM
Old 11-18-2011
passing variable content to a function

following on from below link
HTML Code:
https://www.unix.com/shell-programming-scripting/171076-shell-scripting.html#post302573569
i will be using file reading in while loop say for example
Code:
 
while read line123
do
        echo "line read is $line123"
        insert_funct $line123
done< mysqldump.sql
 
inser_funct()
{
    echo $1
}

here say the mysqldump.sql has a line

`reserved2` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`reserved3` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL

it reads the first line and it will be stored in line123 variable in while loop but when i pass this to a function insert_funct i am able to receive only `reserved` and rest of the content is not visibile. if i echo in while loop its showing whole line and in function its showing clipped one. if you see the html link of my previous code i have two function. in one function i need only `reserved` which is column name and in other i need whole line. but as i said before am able to receive only `reserved` even then i am not able to perform string manipulation on that. its length is shown null etc etc.

any help is deeply appreciated
regards,
vivek
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing a variable name to be created within a function

Is it possible to pass a variable name, as a parameter to a function, so it can be created within this function ? Something like this: func_uppercase abcdefgh var_name where the 1st parameter is the string I want to convert and the 2nd is the desired variable name... $2=`echo "$1" |... (2 Replies)
Discussion started by: 435 Gavea
2 Replies

2. UNIX for Dummies Questions & Answers

passing variable to function

Hi, I am trying to sum up numbered columns and in order to tidy up the program I have wrote a function to do the adding of some numbers. I have a problem though with passing a variable to the function in the UNIX bash shell. The function only gives the first number in the variable list and does... (4 Replies)
Discussion started by: Knotty
4 Replies

3. UNIX for Advanced & Expert Users

Passing a unix variable value to a Plsql function

Suppose I have a unix variable called RGNM which is holding a value. Now I want to call a plsql function in my script. THis plsql function takes one IN parameter. I want to pass my UNIX VARIABLE Value to the plsql function. Can i just give it by giving $RGNM in the function after calling sqlplus... (1 Reply)
Discussion started by: cobroraj
1 Replies

4. UNIX for Dummies Questions & Answers

passing a variable inside a variable to a function

I would like to know how to pass a variable inside a variable to a function. sample code below -------------- for x in 1 9 do check_null $C$x ##call function to check if the value is null if then echo "line number:$var_cnt,... (2 Replies)
Discussion started by: KingVikram
2 Replies

5. Shell Programming and Scripting

Passing global variable to a function which is called by another function

Hi , I have three funcions f1, f2 and f3 . f1 calls f2 and f2 calls f3 . I have a global variable "period" which i want to pass to f3 . Can i pass the variable directly in the definition of f3 ? Pls help . sars (4 Replies)
Discussion started by: sars
4 Replies

6. Shell Programming and Scripting

Passing the parameters using a function

Hi All, I am new to shell scripting required some help in passing the parameter value to the shell script. I am writing a shell script, in the script I have created two functions as below. first function get_trend_ids () { Here I am connecting to the database and getting all the... (3 Replies)
Discussion started by: shruthidwh
3 Replies

7. Shell Programming and Scripting

Passing file content as parameter

Hi All, I am passing a file value as parameter to awk command; Par.txt A|B Input.txt A,1 B,3 C,4 D,5 My desired output should be A,1 B,3 (4 Replies)
Discussion started by: kmsekhar
4 Replies

8. Programming

PASSING PART OF FILE CONTENT TO VARIABLE

All, I have a log file containing lots of data now i want to extract all text between block below(names) without the title or end pattern but only names, ++++START++++ SCOTT TIGER HENRY PAUL JARED OTIENO OMOLLO JA NIGERIA ++++END++++ the names i want to return and store in a variable in... (1 Reply)
Discussion started by: Scott2000
1 Replies

9. UNIX for Advanced & Expert Users

Passing variable as input & storing output in other variable

I have a below syntax its working fine... var12=$(ps -ef | grep apache | awk '{print $2,$4}') Im getting expected output as below: printf "%b\n" "${VAR12}" dell 123 dell 456 dell 457 Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Discussion started by: sam@sam
5 Replies

10. Shell Programming and Scripting

Passing variable value in a function to be used by another function

Hello All, I would like to ask help from you on how to pass variable value from a function that has been called inside the function. I have created below and put the variables in " ". Is there another way I can do this? Thank you in advance. readtasklist() { while read -r mod ver... (1 Reply)
Discussion started by: aderamos12
1 Replies
mysqmail-dovecot-logger(8)				      System Manager's Manual					mysqmail-dovecot-logger(8)

NAME
mysqmail-dovecot-logger - logs dovecot-imapd and dovecot-pop3d traffic to a mysql database SYNOPSIS
mysqmail-dovecot-logger subprogram [ args ... ] DESCRIPTION
mysqmail-dovecot-logger reads the syslog using tail -F, and for each dovecot lines of POP3 and IMAP corresponding to a disconnection, mysq- mail-dovecot-logger writes the total used bandwidth corresponding to the username. Configuration is read from /etc/mysqmail.conf. mysqmail-dovecot-logger uses a table corresponding to this one: CREATE TABLE IF NOT EXISTS pop_access ( id varchar(32) NOT NULL default '', uid int(11) NOT NULL default '65534', gid int(11) NOT NULL default '65534', home varchar(255) NOT NULL default '', shell varchar(255) NOT NULL default '', mbox_host varchar(120) NOT NULL default '', crypt varchar(50) NOT NULL default '', passwd varchar(50) NOT NULL default '', active int(11) NOT NULL default '1', start_date date NOT NULL default '0000-00-00', expire_date date NOT NULL default '0000-00-00', quota_size int(11) NOT NULL default '0', type varchar(20) NOT NULL default 'default', memo text,du bigint(20) NOT NULL default '0', another_perso varchar(5) NOT NULL default 'no', redirect1 varchar(255) default NULL, redirect2 varchar(255) default NULL, localdeliver varchar(10) NOT NULL default 'yes', pop3_login_count int(9) NOT NULL default '0', pop3_transfered_bytes int(14) NOT NULL default '0', imap_login_count int(9) NOT NULL default '0', imap_transfered_bytes int(14) NOT NULL default '0', last_login int(14) NOT NULL default '0', PRIMARY KEY (id,mbox_host) ) TYPE=MyISAM VERSION
This documentation describes mysqmail-dovecot-logger version 0.4.4 or superior. See http://gplhost.com/softwares-mysqmail.html for updates. SEE ALSO
qmail-send(3), syslog(3), logger(8) mysqmail-dovecot-logger(8)
All times are GMT -4. The time now is 06:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy