10-26-2011
Make script that run with argument if not run from configuration file argument
Hello,
Is there any method thorugh which script can take argument if pass otherwise if argument doesn't pass then it takes the argument from the configuration file
i.e I am workiing on a script which will run through crontab and the script will
chekout the code ,zip and copy to the particular location.
But the script should be in this way
if someone pass the argument then it will checkout that code else if argument doesn't pass then it will take the argument from the configuration file.
Thanks
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi folks
I have a unix script script1 in a directory folder1 and also I have few input log files in this directory. My input log files will be copied into this directory folder1 from the portable thumb drive.
Now what I want is I need to run this script1 whenever any new file is copied... (2 Replies)
Discussion started by: ks_reddy
2 Replies
2. Shell Programming and Scripting
Can someone please help me with this SHELL script?
I need to create a script that gets a positive number n as an argument. The script must calculate the factorial of its argument. In other words, it must calculate n!=1x2x3x...xn. Note that 0!=1.
Here is a start but I have no clue how to... (3 Replies)
Discussion started by: I-1
3 Replies
3. Shell Programming and Scripting
I have created shell script to run sql query something like below. i can use this script with only few arguments. But how can i modify the script if empno is huge in numbers.
For example
./script.ksh 1234
select *
from emp
where empno in $1 (2 Replies)
Discussion started by: ford2020
2 Replies
4. Shell Programming and Scripting
Hi All,
I have a question regarding running this script by passing an argument, for example ./ShellParse.sh sun, how do i do that? So i want when i pass argument sun, it shouild execute things inside the for loop. I want to support some other platforms too, so there are more for loops to... (3 Replies)
Discussion started by: asirohi
3 Replies
5. Shell Programming and Scripting
Hi All,
I want to run a bash script using perl. But they are in the different dir.
#! /usr/bin/perl -w
use strict;
my $root=`pwd`;
chomp($root);
my $cmd=".$root/testdir/ft_623.sh 3 4 5 6 7";
print $cmd;
my @line=`$cmd`;
foreach (@line){
print $_;
}
ft_623.sh (0 Replies)
Discussion started by: Damon sine
0 Replies
6. Shell Programming and Scripting
If ($argv == “-debug”) then
Echo “in loop”
Endif
But this is not working. If I modify this code and remove “-“, then it works.
Similarly I am getting problem using grep command also
Grep “-debug” Filename
Can someone please help me on how to resolve these... (1 Reply)
Discussion started by: sarbjit
1 Replies
7. UNIX for Advanced & Expert Users
Hi All,
I am running the script
VBoxManage list vms |sed 's/"//g' | cut -d " " -f1 > har1out.mytxt
result=`cat har1out.mytxt | grep $1'
echo $result
echo $1
{
if
then
echo pass
else
echo fail
fi (2 Replies)
Discussion started by: harsha85
2 Replies
8. Shell Programming and Scripting
I have this little bash script I use to transcode mkv files using handbrake.
#!/bin/bash
sourcedir="/media/raid10/video/to_be_encoded_series"
destdir="/media/raid10/video/series"
cd "$sourcedir"
for i in *.mkv; do
HandBrakeCLI -i "$i" -o "$destdir/${i%.*}.mkv" -e x264 -q 20.0 -E copy -B... (4 Replies)
Discussion started by: barrydocks
4 Replies
9. Shell Programming and Scripting
Hello Friends,
I need you help !
I have a scripts names runsteps.sh which contains command to run bunch of commands for each application you want to install " Oracle " Jboss" etc
echo " Which app you want to install Jboss" ? Yes or no?
read ans
depending on Yes or not it goes inside... (3 Replies)
Discussion started by: saurabh84g
3 Replies
10. Shell Programming and Scripting
Linux System having all Perl, Python, PHP (and Ruby) installed
From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file
eg
eg
a Shell script run in a case statement call to run a php file, also Perl or/and Python file???
Like
#!/usr/bin/bash
....
....
case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies
LEARN ABOUT DEBIAN
test::script::run
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)