Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to pass command line argument in shell script? Post 302848555 by RudiC on Thursday 29th of August 2013 01:48:33 PM
Old 08-29-2013
Search these fora - there's many an example of exactly your request.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Passing command line argument between shell's

Hi, I am facing a problem to pass command line arguments that looks like <script name> aa bb "cc" dd "ee" I want to pass all 5 elements include the " (brackets). when I print the @ARGV the " disappear. I hope I explain myself Regards, Ziv (4 Replies)
Discussion started by: zivsegal
4 Replies

2. Shell Programming and Scripting

Pass command line argument to variable

Hi, I had written a shell script to pass command line argument to variable in a function. Here is my code: main if ; then .$1 echo $1 get_input_file else echo "input file $1 is not available" fi get_input_file() { FILE = "$1" echo $FILE } (10 Replies)
Discussion started by: Poonamol
10 Replies

3. Shell Programming and Scripting

shell script for ftp files passed in command line argument

i want to write a shell script function that will ftp the files passed in the command line . i have written a shell script for ftp but how will it do for all files passed in command line argument , i am passing 4 files as argument ./ftp.sh file1 file2 file3 file4 code written by me... (5 Replies)
Discussion started by: rateeshkumar
5 Replies

4. Shell Programming and Scripting

How we can pass the argument when calling shell script from perl script

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

5. Shell Programming and Scripting

How to pass a filename as a command line argument

Hi,I have a script which is given below :#!/bin/bash. ini_script.shdb2 connect to $DB_NAME user $DB2_UID using $DB2_PASSWORDfor file in `ls -1 ./sql/ddw/`do echo "Executing the file $file" echo db2 -tvf $filedonedb2 quiti want this script to accept directorie's names present in... (1 Reply)
Discussion started by: ektubbe
1 Replies

6. Programming

How to pass the command line arguments to the shell script in c language?

hi, I am new in the shell script, and c programming with linux. I am looking to pass the arguments in c program that should be executed by the shell script. e.g. #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv) { int i; for (i=1;i<argc; i++) { ... (2 Replies)
Discussion started by: sharlin
2 Replies

7. Shell Programming and Scripting

How to pass command line argument in shell script?

I need to write a shell script, when I run that script I should pass those arguments if not, then script should not run and pass the error message like invalid option - - should pass the argument. and Exit from the script https://www.unix.com/images/misc/progress.gif (1 Reply)
Discussion started by: Nsharma3006
1 Replies

8. Shell Programming and Scripting

Pass file as one of argument in shell

Hi, Is there any way that we can pass one file as one of the argument in shell script ? (1 Reply)
Discussion started by: Selva_2507
1 Replies

9. Shell Programming and Scripting

How to pass Oracle sql script as argument to UNIX shell script?

Hi all, $ echo $SHELL /bin/bash Requirement - How to pass oracle sql script as argument to unix shell script? $ ./output.sh users.sql Below are the shell scripts and the oracle sql file in the same folder. Shell Script $ cat output.sh #!/bin/bash .... (7 Replies)
Discussion started by: a1_win
7 Replies

10. Shell Programming and Scripting

How to pass each line of a text file as an argument to a command?

I'm looking to write a script that takes a .txt filename as an argument, reads the file line by line, and passes each line to a command. For example, it runs command --option "LINE 1", then command --option "LINE 2", etc. I am fetching object files from a library file, I have all the object file... (2 Replies)
Discussion started by: Paul Martins
2 Replies
Test::Script::Run(3pm)					User Contributed Perl Documentation				    Test::Script::Run(3pm)

NAME
Test::Script::Run - test the script with run SYNOPSIS
use Test::Script::Run; # customized names of bin dirs, default is qw/bin sbin script ./; @Test::Script::Run::BIN_DIRS = qw/bin/; run_ok( 'app_name', [ app's args ], 'you_app runs ok' ); my ( $return, $stdout, $stderr ) = run_script( 'app_name', [ app's args ] ); run_output_matches( 'app_name', [app's args], [ 'out line 1', 'out line 2' ], [ 'err line 1', 'err line 2' ], 'run_output_matches' ); run_output_matches_unordered( 'app_name', [ app's args ], [ 'out line 2', 'out line 1' ], [ 'err line 2', 'err line 1' ], 'run_output_matches_unordered' ); DESCRIPTION
This module exports some subs to help test and run scripts in your dist's bin/ directory, if the script path is not absolute. Nearly all the essential code is stolen from Prophet::Test, we think subs like those should live below "Test::" namespace, that's why we packed them and created this module. FUNCTIONS
run_script($script, $args, $stdout, $stderr) Runs the script $script as a perl script, setting the @INC to the same as our caller. $script is the name of the script to be run (such as 'prophet'). $args is a reference to an array of arguments to pass to the script. $stdout and $stderr are both optional; if passed in, they will be passed to IPC::Run3's run3 subroutineA as its $stdout and $stderr args. Otherwise, this subroutine will create scalar references to pass to run3 instead (which are treated as strings for STDOUT/STDERR to be written to). Returns run3's return value and, if no $stdout and $stderr were passed in, the STDOUT and STDERR of the script that was run. run_ok($script, $args, $msg) Runs the script, checking that it didn't error out. $script is the name of the script to be run (e.g. 'prophet'). $args is an optional reference to an array of arguments to pass to the script when it is run. $msg is an optional message to print with the test. If $args is not specified, you can still pass in a $msg. Returns nothing of interest. run_not_ok($script, $args, $msg) opposite of run_ok get_perl_cmd($script, @ARGS) Returns a list suitable for passing to "system", "exec", etc. If you pass $script then we will search upwards for it in @BIN_DIRS is_script_output($scriptname @args, @stdout_match, @stderr_match, $msg) Runs $scriptname, checking to see that its output matches. $args is an array reference of args to pass to the script. $stdout_match and $stderr_match are references to arrays of expected lines. $msg is a string message to display with the test. $stderr_match and $msg are optional. (As is $stdout_match if for some reason you expect your script to have no output at all. But that would be silly, wouldn't it?) Allows regex matches as well as string equality (lines in $stdout_match and $stderr_match may be Regexp objects). run_output_matches($script, $args, $exp_stdout, $exp_stderr, $msg) A wrapper around is_script_output that also checks to make sure the test runs without throwing an exception. run_output_matches_unordered($script, $args, $exp_stdout, $exp_stderr, $msg) This subroutine has exactly the same functionality as run_output_matches, but doesn't impose a line ordering when comparing the expected and received outputs. last_script_stdout return last script's stdout last_script_stderr return last script's stderr last_script_exit_code return last script's exit code DEPENDENCIES
Test::More, Test::Exception, IPC::Run3, File::Basename, File::Spec BUGS AND LIMITATIONS
No bugs have been reported. AUTHOR
sunnavy "<sunnavy@bestpractical.com>" LICENCE AND COPYRIGHT
Copyright 2009 Best Practical Solutions. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2011-01-07 Test::Script::Run(3pm)
All times are GMT -4. The time now is 01:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy