Sponsored Content
Top Forums Shell Programming and Scripting Unable to execute find command from inside a shell script Post 303045496 by mohtashims on Saturday 28th of March 2020 04:17:23 AM
Old 03-28-2020
Unable to execute find command from inside a shell script

I have a shell script with 775 permission as below

/app/script/test.sh

Code:
#!/bin/bash
/usr/bin/find /app/Jenkins/home/jobs/test1/builds -type d -mtime 1 |  xargs rm -rf
/usr/bin/find /app/Jenkins/home/jobs/test2/builds -type d -mtime 1 |  xargs rm -rf

When i execute the script it simply runs without the find command getting executed and the files being deleted.

Both the find commands work fine when i execute them manually from the terminal.

I want the script to run both the find commands and perform their respective tasks.

i tried to put backticks `` around the find command but still no luck.

Can you please suggest ?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute command inside while problem

Hi! How can I execute a linux command inside the while cicle?? like: This doesn't work. Should I replace the by '' or "" (3 Replies)
Discussion started by: ruben.rodrigues
3 Replies

2. Shell Programming and Scripting

deleting files inside shell script - ( using find)

Hi, I am using the command find /apps/qualdb/gpcn/scripts/cab_outbound/archive -name 'z*' -mtime +28 -exec rm {} \; in unix command prompt for deleting the files in my unix system under the specfied folder. It was succesfull. But when i running this command inside a shell script name... (2 Replies)
Discussion started by: Jayaram.Nambura
2 Replies

3. Shell Programming and Scripting

Execute a shell script after a particular command is run

Hi, I need to run a script whenever the Cron file is modified. The requirement is whenever a user modifies the cron file, the script should run automatically. Can you please provide your inputs ? (5 Replies)
Discussion started by: harneet2004us
5 Replies

4. Shell Programming and Scripting

How to monitor a command inside shell script

Hi All, Is there any way to monitor a command inside shell script ? I have a script inside which I have a tar command which zips around 200GB data. tar zcvf $Bckp_Dir/$Box-BaseBackup-$Day.tar.gz * --exclude 'dbserver_logs/*' --exclude postmaster.pid --exclude 'pg_xlog/*' I want to... (3 Replies)
Discussion started by: sussus2326
3 Replies

5. UNIX for Dummies Questions & Answers

Unable to execute the complete cmd - using find command

Hi, I'm unable to execute the below command completely ; it's not allowing me to type the complete command. It is allowing till "xargs" and i cannot even press enter after that. I'm using Solaris. Let me know if anything needs to be added so as to execute the complete command. Appreciate... (12 Replies)
Discussion started by: venkatesht
12 Replies

6. Shell Programming and Scripting

When i am trying to execute export command within a shell script it is saying command not found.

I am running the export command within a view to use that value inside my build script. But while executing it it is saying "export command not found" My code is as follows: -------------------------- #!/bin/sh user="test" DIR="/bldtmp/"$user VIEW="test.view1" echo "TMPDIR before export... (4 Replies)
Discussion started by: dchoudhury
4 Replies

7. Shell Programming and Scripting

Can i use if else inside expect command in shell script?

hii,, I am trying to automate jira. during my scripting using bash script, in the terminal i got the terminal message like this: "Configure which ports JIRA will use. JIRA requires two TCP ports that are not being used by any other applications on this machine. The HTTP port is where you... (1 Reply)
Discussion started by: nithinfluent
1 Replies

8. Shell Programming and Scripting

How to find whether a particular command has failed inside an sftp script?

hi, how can i know whether a command inside an sftp script has failed or not? i have a sftp expect script #!/usr/bin/expect spawn /usr/bin/sftp abc@ftp.abc.com expect "sftp>" send "cd dir\r" expect "sftp>" send "mput abc.txt\r" expect "sftp>" send "mput def.xls\r" expect "sftp>"... (5 Replies)
Discussion started by: Little
5 Replies

9. Shell Programming and Scripting

How to execute a command inside a while loop?

How do we execute a command inside a while loop? (7 Replies)
Discussion started by: Little
7 Replies

10. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
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 05:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy