Sponsored Content
Top Forums Shell Programming and Scripting Passing Value from Shell to Perl Post 302143938 by hcbhatt on Monday 5th of November 2007 12:36:34 PM
Old 11-05-2007
Quote:
Originally Posted by porter
The four primary ways of inputting some to a program (no matter the language the program is written in)

(a) command line argument, like your file argument

(b) environment variables, typically need to export from a shell script

(c) as stdin, basically the input stream to a program

(d) as a generic file, where the program looks for well-known files.
I have tried
export $MY_VARIABLE

and then reading $MY_VARIABLE in perl program. I didnt get any value!

I tried as command line argument, however since I already have one file as input paramenter, it is interpreting another also as file input and I get a message that $MY_VARIABLE file does not exists.

Can you please show me syntax of passing file as one parameter and value as another parameter? or any other way?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing variable to perl

I need a non-perl (bash) way to strip the path from a list of "find" results. Below is the perl version which I could use, if I could figure out how to call the script with a variable (like in sh, $1 is the variable passed in ./script variable) $file = "/path/to/file.txt"; # How do I... (2 Replies)
Discussion started by: TheCrunge
2 Replies

2. Shell Programming and Scripting

Need help passing variables in shell script to perl one-liner

I'm writing a script to automate some post-install tasks on RHEL4 servers. I need the following code to insert an 'A' in the middle of a string, then replace the string in a file. I know I can use sed to do this, but I'd like to use perl's in place edit so I don't have to write to a temp file,... (1 Reply)
Discussion started by: Xek
1 Replies

3. Shell Programming and Scripting

Passing a file handler and an array from Perl to Shell Script

Hi there, I am trying to call a shell script from a Perl script. here is the code: @args = ("sh", "someshellprg.sh", "a file handler", "an array"); system(@args) == 0 or die "system @args failed: $?"; in the shell program, I examine if the arguments exits using: if then echo... (5 Replies)
Discussion started by: pinkgladiator
5 Replies

4. Shell Programming and Scripting

passing a hash to another script in perl

I have a script (say script1.sh ) and I am calling a script (say script2.sh) within the script1.sh. Here in script1.sh I have a hash ( say %hash1) and i have to pass this hash to script2.sh. Basically i have to do some processing in Scirpt2.sh based on the hash(key,values). I wanted to know how can... (2 Replies)
Discussion started by: ammu
2 Replies

5. Shell Programming and Scripting

Passing arguments to Perl Function

Hi All, I am trying to pass an argument called "Pricelist" to a Perl function, then the function will open and print out the contents of the file named "Pricelist". But i can't seem to do it using my below code. Can any expert give some advice? #!/usr/local/bin/perl $DATABASE =... (1 Reply)
Discussion started by: Raynon
1 Replies

6. Shell Programming and Scripting

Passing date formats in Perl: i.e. Jul/10/2007 -> 20070710 (yyyymmdd) - Perl

Hi , This script working for fine if pass script-name.sh Jul/10/2007 ,I want to pass 20070710(yyyymmdd) .Please any help it should be appereciated. use Time::Local; my $d = $ARGV; my $t = $ARGV; my $m = ""; @d = split /\//, $d; @t = split /:/, $t; if ( $d eq "Jan" ) { $m = 0 }... (7 Replies)
Discussion started by: akil
7 Replies

7. Shell Programming and Scripting

Passing perl variable to shell command

Can we pass perl variable to shell commands. If yes, please give some example. (2 Replies)
Discussion started by: Anjan1
2 Replies

8. Shell Programming and Scripting

Passing PERL var values to SH Shell Script

Greetings all, If I have a SH script that calls a PERL script in the following way: perl $HOME/scripts/config.properties And in the config.properties PERL file, this Perl script only sets a number of environmental parameters in the following way: #!/usr/bin/perl $VAR1 = ( ... (3 Replies)
Discussion started by: gikyo12
3 Replies

9. Shell Programming and Scripting

Problems passing shell arguments to perl

Semi-newbie, so flame throwers to 'singe-only', please. ;-) I have a large number of (say) .html files, where I'd like to do a recursive in-place search and replace a particular string. The following bit of perl works fine: perl -pi -e 's/oldstring/newstring/g' `find ./ -name *.html` ... (2 Replies)
Discussion started by: johnny_canucl
2 Replies

10. Shell Programming and Scripting

Converting shell to Perl I run into shell built in function trap and need alternative in Perl

I am working on converting shell to Perl script. In shell we have built in function trap Do you know alternative in Perl or actually we don't need it? Thanks for contribution (3 Replies)
Discussion started by: digioleg54
3 Replies
FUZZ(1) 						      General Commands Manual							   FUZZ(1)

NAME
fuzz - stress test programs SYNOPSIS
fuzz [-t|--timeout timeinsecs] [-p|--printable] [-n|--newlines N] [-l|--length totlen] [-m|--maxline maxlinelen] [-r|--runcount numruns] [-b|--bytes] [-c|--chroot] [-u|--user username] [-a|--args] [-o|--omitdata] [-e|--execute filename] [-x|--maxargs numargs] [-d|--dontask] [-y|--mararglen arglen] [-V|--version] [-i|--priority] target targetarg... DESCRIPTION
fuzz is a program designed to find bugs in other programs. It does this by doing a form of black box testing. It does this by running the target program multiple times and passing it random input. Right now this can come from one of two places, stdin and the command line argu- ments. Testing completes whenever the program either the requested number of runs finishes successufully or the program crashes. Any arguments following the target program are passed directly to the target program. NOTE: If the program is not in PATH, it must be referred to using absolute path. OPTIONS -a, --args In addition to passing random data via stdin, pass random command line arguments. This simply sets the number or random arguments to be passed to 256. See the BUGS section. -b, --bytes In addition to counting through the number of runs. Count through the bytes being sent through stdin to the program. This option really serves no purpose other than making something interesting to watch. -c, --chroot Since there is no telling what a program will do when given random input. this allows a program to be sort of caged while it is run so that the damage that it may be able to do is minimized. This requires that the fuzz be run as root. It will drop privlages before it runs the test program. This option is best used in conjunction with the --user option. This often times requires that a program is statically linked. -d, --dontask In the cases where the target program is for sure part of a package and the packaging information will provide the needed version information then you can use this option to avoid being asked what the version is. -i, --priority Run at a specified priority. -l, --length LENGTH The length in bytes of the data stream to pass through stdin into the target program. The default length is 100K. -m, --maxline MAXLINELEN Specify the maximum line length within the random data stream passed into stdin. -n, --newlines N Include random N newlines in the input stream. -o, --omitdata Some programs don't take input from stdin. They only take input from the command line arguments. If this is the case simply use the --omitdata option. -p, --printable This limits both the stdin and the command line arguments to only printable characters. By default fuzz passes fully random bytes into the target program. -r, --runcount RUNCOUNT The number of times to run the target program. The default is 10,000. -t, --timeout TIME This sets the number of seconds that the fuzz will wait for the other program before it assumes that the program is hung. The default value is 120 seconds. This is sensing of when a program is hung is not entirely reliable. See the BUGS section. -u, --user USERNAME Since there is no telling what a program will do when given random input, this specifies what user the target program will be run as so that it is easy to find and repair anything that may have been scribbled across your file system. This option was designed to be used in conjuntion with the --chroot option and will only work if fuzz is run as root. -V, --version Print the version of fuzz and exit. -x. --maxargs NUMARGS This is to set the maximum number of arguments that are passed to each invocation of the target program. -y, --maxarglen ARGLEN Sets the maximum length of an arguments passed to the target program. EXAMPLES
Check grep: fuzz grep foo Run program with different user: fuzz --chroot --user nobody cpio -i When program is not in path, use absolute patch to access it: fuzz ./src/myprogram BUGS
The random arg functions doesn't work very well right now. The arguments passed are so random that the program usually just prints out the usage message and then terminates. This will become much more useful later when we are mating data sets with the intention of maximizing code coverage. AUTHORS
Ben Woodard <ben@valinux.com> 3rd Berkeley Distribution November 3, 1999 FUZZ(1)
All times are GMT -4. The time now is 10:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy