Sponsored Content
Top Forums Shell Programming and Scripting Passing arguments to the subshell Post 302406358 by bakunin on Monday 22nd of March 2010 04:33:13 PM
Old 03-22-2010
Why don't you post the scripts (or the relevant portions of them) here? It is - if you allow me this analogy - difficult to suggest a move in a chess position you are not allowed to even look at - even for a good player.

Second, why don't you give my suggestion a try? Exporting a variable is like creating a global variable in a normal programming language: bad programming style and very probably leading to problems sooner or later.

bakunin
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

passing arguments

I'm trying to pass a filename, or all the files in the current directory to the ls command with a script. Unsuccessful so far, here are a few of my attempts: #!/bin/ksh read fname #if (( $# > 0 )); then $fname | ls -l #fi this produces a long listing of all the files in my current... (4 Replies)
Discussion started by: jpprial
4 Replies

2. Shell Programming and Scripting

passing of a varibale to subshell

Hi All, I need some info. Could you please tell me how to use the variable of a parent shell in the subshell. Also can we modify the variable in the subshell ? If yes, will the modified variable visible in the parent shell I am using two prg. a.sh #!/usr/bin/ksh temp_var="abhishek"... (3 Replies)
Discussion started by: AbhishekG
3 Replies

3. Shell Programming and Scripting

Passing Arguments-Help

Hi, I have a script which adds the user credentials to an ldap server. Im passing the variables as below.. /path/my_script $uname $pwd $environ ${deposit} If i enter some special characters like ';' in $pwd, script returns an error which is set to display if the user enters... (5 Replies)
Discussion started by: Tuxidow
5 Replies

4. Shell Programming and Scripting

passing arguments

Hi I have a script to which I pass multiple arguments, for example lets say the script name is "abc". I run the script like ./abc def /file <directory location> In the above "def" is the first argument and "/file" is the second argument. I expect <directory location> that is passed after... (4 Replies)
Discussion started by: zmfcat1
4 Replies

5. UNIX for Dummies Questions & Answers

Passing arguments

I need to pass arguments to a shell script.My batch is calling some java program. ################# x=$1 y=$2 java -classpath program ################### if first parameter and second parameter is null then java -classpath program if first parameter is not null and second parameter is... (3 Replies)
Discussion started by: mnjx
3 Replies

6. Shell Programming and Scripting

Passing arguments to csh

I have noticed this thing using csh when passing arguments Suppose I call a csh script using ../Scripts/plot-model.csh -vmod="npt02-z30.vmod" -R="0/80/0/30" -c="0/4.5" -aspr="1:10" Somehow the " get removed when doing $argv ending up with -vmod=npt02-z30.vmod... (0 Replies)
Discussion started by: kristinu
0 Replies

7. Shell Programming and Scripting

Passing arguments at runtime

Hi .. Can any one please tell how to pass argument to shell script at runtime? I want to implement funcnality just like bc, where we can provide input while script is running and can be used later in the same script. Thanks in advance... (1 Reply)
Discussion started by: kunjalhg
1 Replies

8. Shell Programming and Scripting

Reading a string and passing passing arguments to a while loop

I have an for loop that reads the following file cat param.cfg val1:env1:opt1 val2:env2:opt2 val3:env3:opt3 val4:env4:opt4 . . The for loop extracts the each line of the file so that at any one point, the value of i is val1:env1:opt1 etc... I would like to extract each... (19 Replies)
Discussion started by: goddevil
19 Replies

9. Shell Programming and Scripting

Passing arguments--Error

Hi, i have a file.txt with data Bangalore Chennai Hyd filename of the script is: new.sh result=`cat file.txt | grep $1` if then echo pass else echo fail fi i am executing the file in the cmd line as "sh new.sh Bangalore" o/p is pass if i give "sh new.sh delhi" o/p is... (6 Replies)
Discussion started by: harsha85
6 Replies

10. Shell Programming and Scripting

Passing multiple arguments

Hi, I know with getopts you can pass arguments from the command line ./script -ab -c apple But it doesn't support 2 or more arguments for ONE option. Is there any other way to do this? Thanks (2 Replies)
Discussion started by: testa500
2 Replies
LexAlias(3pm)						User Contributed Perl Documentation					     LexAlias(3pm)

NAME
Devel::LexAlias - alias lexical variables SYNOPSIS
use Devel::LexAlias qw(lexalias); sub steal_my_x { my $foo = 1; lexalias(1, '$x', $foo); } sub foo { my $x = 22; print $x; # prints 22 steal_my_x; print $x; # prints 1 } DESCRIPTION
Devel::LexAlias provides the ability to alias a lexical variable in a subroutines scope to one of your choosing. If you don't know why you'd want to do this, I'd suggest that you skip this module. If you think you have a use for it, I'd insist on it. Still here? lexalias( $where, $name, $variable ) $where refers to the subroutine in which to alias the lexical, it can be a coderef or a call level such that you'd give to "caller" $name is the name of the lexical within that subroutine $variable is a reference to the variable to install at that location BUGS
lexalias delves into the internals of the interpreter to perform its actions and is so very sensitive to bad data, which will likely result in flaming death, or a core dump. Consider this a warning. There is no checking that you are attaching a suitable variable back into the pad as implied by the name of the variable, so it is possible to do the following: lexalias( $sub, '$foo', [qw(an array)] ); The behaviour of this is untested, I imagine badness is very close on the horizon though. SEE ALSO
peek_sub from PadWalker, Devel::Peek AUTHOR
Richard Clamp <richardc@unixbeard.net> with close reference to PadWalker by Robin Houston COPYRIGHT
Copyright (c) 2002, Richard Clamp. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. perl v5.14.2 2002-07-25 LexAlias(3pm)
All times are GMT -4. The time now is 01:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy