08-18-2011
When you execute it as ./setUP, a child shell is invoked first and them the setUP script is invoked in the child shell. So the var_name is set in that (child) shell and is available to it and its children - not its parent.
By invoking it as . ./setUP, you are asking the shell to execute the script in the current shell. Hence, var_name is visible to your current shell.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi friends,
i'm new to unix and straight away i had to start with the script files.
I've a script file which gets called from a menu item on a GUI.
This script file again calls .awk file, in performing some tasks , which also generates certain files.
I modified the files to generate some... (1 Reply)
Discussion started by: Ravi_Kandula
1 Replies
2. Shell Programming and Scripting
Hello Friends,
I have bash script on unix server which i want to call from windows server. Basically i want a command line which will call this script on unix server. Any one has any idea regarding this?
Help really appreciated!!
Thanks,
Roshni. (1 Reply)
Discussion started by: onlyroshni
1 Replies
3. Shell Programming and Scripting
Hi,
I have a query ..
i have 2 scripts say 1.sh and 2.sh
1.sh contains many functions written using shell scripts.
2.sh is a script which needs to call the functions definded in 1.sh
function calls are with arguments.
Can some one tell me how to call the functions from 2.sh?
Thanks in... (6 Replies)
Discussion started by: jisha
6 Replies
4. Shell Programming and Scripting
Hi there,
I have an script reading content of a file and runs whatever command is specified there, as follows
#!/bin/bash
# Supposed to read from a file that commands are listed to be run
# when the server starts for initialization
CMD_FILE=/myScripts/startup/task2do.txt
if ; then
... (2 Replies)
Discussion started by: james gordon
2 Replies
5. Shell Programming and Scripting
Hello gurus,
I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script.
i m looking for something like this
call 3.1;
If 3.1 = "complete" then
call 3.2;
if 3.2 = ''COMPlete" then
call 3.3;
else
exit
The... (1 Reply)
Discussion started by: shashi369
1 Replies
6. Shell Programming and Scripting
Hello - I have a small diff script that checks 2 directories. It reports the difference in count such as wc -l, and also names the different files.
How should I get "ERROR: diff found . (host)" - when it actually finds a diff?
This is how I have written:
#!/bin/bash
... (10 Replies)
Discussion started by: DallasT
10 Replies
7. Shell Programming and Scripting
Hi all ,
i am trying to calculate time difference btw the script execution
I am using solaris
start_time=`date +%s`
sleep 2
end_time=`date +%s`
duration=`expr $end_time - $start_time`
when i try to subtract i get the error
line 13: %s - -time : syntax error: operand expected... (3 Replies)
Discussion started by: posner
3 Replies
8. Shell Programming and Scripting
Hi ALL
I have a shell script named setUP in which i am sourcing one variable like
source var_name="CLASSPATH".
When i call it as ./setUP, it does not set the var_name variable. But when i call it like . ./setUP then var_name is set up. What is the difference between this two calls?
... (2 Replies)
Discussion started by: SasDutta
2 Replies
9. Shell Programming and Scripting
Hi,
I am new to shell scripting.
please help me to find out the solution.
I need a script where we need to read the text file(consists of all file names) and get the file names one by one
and append the date suffix for each file name as 'yyyymmdd' .
Then search each file if exists... (1 Reply)
Discussion started by: Lucky123
1 Replies
10. Shell Programming and Scripting
Can someone let me know how could I achieve this
In one of per script I am calling the shell script but I need to so one thing that is one shell script call I need to pass pne argument.In below code I am calling my ftp script but here I want to pass one argument so how could I do this (e.g:... (5 Replies)
Discussion started by: anuragpgtgerman
5 Replies
LEARN ABOUT DEBIAN
padwalker
PadWalker(3pm) User Contributed Perl Documentation PadWalker(3pm)
NAME
PadWalker - play with other peoples' lexical variables
SYNOPSIS
use PadWalker qw(peek_my peek_our peek_sub closed_over);
...
DESCRIPTION
PadWalker is a module which allows you to inspect (and even change!) lexical variables in any subroutine which called you. It will only
show those variables which are in scope at the point of the call.
PadWalker is particularly useful for debugging. It's even used by Perl's built-in debugger. (It can also be used for evil, of course.)
I wouldn't recommend using PadWalker directly in production code, but it's your call. Some of the modules that use PadWalker internally are
certainly safe for and useful in production.
peek_my LEVEL
peek_our LEVEL
The LEVEL argument is interpreted just like the argument to "caller". So peek_my(0) returns a reference to a hash of all the "my"
variables that are currently in scope; peek_my(1) returns a reference to a hash of all the "my" variables that are in scope at the
point where the current sub was called, and so on.
"peek_our" works in the same way, except that it lists the "our" variables rather than the "my" variables.
The hash associates each variable name with a reference to its value. The variable names include the sigil, so the variable $x is
represented by the string '$x'.
For example:
my $x = 12;
my $h = peek_my(0);
${$h->{'$x'}}++;
print $x; # prints 13
Or a more complex example:
sub increment_my_x {
my $h = peek_my(1);
${$h->{'$x'}}++;
}
my $x=5;
increment_my_x;
print $x; # prints 6
peek_sub SUB
The "peek_sub" routine takes a coderef as its argument, and returns a hash of the "my" variables used in that sub. The values will
usually be undefined unless the sub is in use (i.e. in the call-chain) at the time. On the other hand:
my $x = "Hello!";
my $r = peek_sub(sub {$x})->{'$x'};
print "$$r
"; # prints 'Hello!'
If the sub defines several "my" variables with the same name, you'll get the last one. I don't know of any use for "peek_sub" that
isn't broken as a result of this, and it will probably be deprecated in a future version in favour of some alternative interface.
closed_over SUB
"closed_over" is similar to "peek_sub", except that it only lists the "my" variables which are used in the subroutine but defined
outside: in other words, the variables which it closes over. This does have reasonable uses: see Data::Dump::Streamer, for example (a
future version of which may in fact use "closed_over").
set_closed_over SUB, HASH_REF
"set_closed_over" reassigns the pad variables that are closed over by the subroutine.
The second argument is a hash of references, much like the one returned from "closed_over".
var_name LEVEL, VAR_REF
var_name SUB, VAR_REF
"var_name(sub, var_ref)" returns the name of the variable referred to by "var_ref", provided it is a "my" variable used in the sub. The
"sub" parameter can be either a CODE reference or a number. If it's a number, it's treated the same way as the argument to "peek_my".
For example,
my $foo;
print var_name(0, $foo); # prints '$foo'
sub my_name {
return var_name(1, shift);
}
print my_name($foo); # ditto
AUTHOR
Robin Houston <robin@cpan.org>
With contributions from Richard Soberberg, Jesse Luehrs and Yuval Kogman, bug-spotting from Peter Scott, Dave Mitchell and Goro Fuji, and
suggestions from demerphq.
SEE ALSO
Devel::LexAlias, Devel::Caller, Sub::Parameters
COPYRIGHT
Copyright (c) 2000-2009, Robin Houston. 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 2012-06-26 PadWalker(3pm)