OS: RedHat
Shell: bash
User: root
no chrooted environment, no special non-printing characters.
First observation: the paths in the script are not absolute paths. This might lead to no directories/files being found when the script is executed in a wrong current path. Change these paths to absolute paths to make the script more robust.
Here is another take at problem determination: modify your script by switching on printing of the interpreted lines:
Code:
#!/bin/bash
set -xv # <--- makes every line being printed to stdout after parsing
fRootDir="/some/path" # set an absolute starting path
find $fRootDir/dir1/dir2 -type f -name "FILE.*" -newer $fRootDir/dir1/dir2/afterme.txt -exec cp {} $fRootDir/dir1/dir2/dir3 \;
exit 0
Now start the script this way:
Code:
root@server # ./myscript.sh 2> myscript.log
and post the contents of the file myscript.log here. I would really be interested in what the problem is here and what the final solution will be.
linux redhat 8.0
I am getting accustomed to using the -exec command to get around my databse.. and use it to edit and update files..! is this more apllicable than jumping from one directory to the other.. I have set up the databse so that the inode #'s are accessable and can get me from one... (0 Replies)
hai
i want know the difference between two shell scripts those are
1)
a=2004
echo $a #output------2004
exec < inputfile
while read line
do
echo $a #output-------2004
a=2005
echo $line
echo $a ... (1 Reply)
All,
I am using below shell script to output the content to outputfile.txt. What I am looking for is in addition to outputfile.txt, I want the output to be on standard output too.
exec > outputfile.txt
echo "Starting "
echo "ending" (5 Replies)
How can I use the exec command to log my korn shell session to the screen and the log file?
Currently I have this command:
$exec 1> ${LOG} 2>&1
This logs the output to the log file only. I want it to go to the screen also. Is this possible with this command?
thanks. (10 Replies)
Hi can some one explain the following command , It would really help if some can really elloborate on what is happening out here
export PATH | exec /bin/sh ./auto_approve :q
P.S: This is the first time i am using exec ,so an elloboration what does it do and what is the use of the :q will be... (1 Reply)
Hi,
I have the following lines in a script :
.
.
exec < some_file
.
.
.
I have very little idea about exec command. I would like to know what this does and what will happen if the file some_file does not exist. Specifically, I would like to know whether the lines following this... (5 Replies)
I have the following bash script lines in a file named test.sh.
#!/bin/bash
#
# Write Date to cron.log
#
echo "Begin SSI Load $(date +%d%b%y_%T)"
#
# Get the latest rates file for processing.
#
d=$(ls -tr /rms/data/ssi | grep -v "processed" | tail -n 1)
filename=$d
export filename... (3 Replies)
Hi all,
Forgive me for asking for help with my first post, but I am struggling here. I've been asked to translate a bash script into a Windows script (probably batch or powershell, not sure yet), so the first step is obviously understand what the bash script is doing. But I have no experience in... (5 Replies)
Hello.
From a script, a command for a test is use :
find /home/user_install -maxdepth 1 -type f -newer /tmp/000_skel_file_deb ! -newer /tmp/000_skel_file_end -name '.bashrc' -o -name '.profile' -o -name '.gtkrc-2.0' -o -name '.i18n' -o -name '.inputrc'
Tha command... (3 Replies)
Discussion started by: jcdole
3 Replies
LEARN ABOUT SUSE
traverse
fileutil_traverse(n) file utilities fileutil_traverse(n)
__________________________________________________________________________________________________________________________________________________NAME
fileutil_traverse - Iterative directory traversal
SYNOPSIS
package require Tcl 8.3
package require fileutil::traverse ?0.4?
::fileutil::traverse ?objectName? path ?option value...?
$traverser command ?arg arg ...?
$traverser files
$traverser foreach filevar script
$traverser next filevar
_________________________________________________________________DESCRIPTION
This package provides objects for the programmable traversal of directory hierarchies. The main command exported by the package is:
::fileutil::traverse ?objectName? path ?option value...?
The command creates a new traversal object with an associated global Tcl command whose name is objectName. This command may be used
to invoke various operations on the traverser. If the string %AUTO% is used as the objectName then a unique name will be generated
by the package itself.
Regarding the recognized options see section OPTIONS. Note that all these options can be set only during the creation of the traver-
sal object. Changing them later is not possible and causes errors to be thrown if attempted.
The object command has the following general form:
$traverser command ?arg arg ...?
Command and its arguments determine the exact behavior of the object.
The following commands are possible for traversal objects:
$traverser files
This method is the most highlevel one provided by traversal objects. When invoked it returns a list containing the names of all
files and directories matching the current configuration of the traverser.
$traverser foreach filevar script
The highlevel files method (see above) is based on this mid-level method. When invoked it finds all files and directories matching
per the current configuration and executes the script for each path. The current path under consideration is stored in the variable
named by filevar. Both variable and script live / are executed in the context of the caller of the method. In the method files the
script simply saves the found paths into the list to return.
$traverser next filevar
This is the lowest possible interface to the traverser, the core all higher methods are built on. When invoked it returns a boolean
value indicating whether it found a path matching the current configuration (True), or not (False). If a path was found it is stored
into the variable named by filevar, in the context of the caller. The foreach method simply calls this method in a loop until it
returned False. This method is exposed so that we are also able to incrementally traverse a directory hierarchy in an event-based
manner.
OPTIONS -prefilter command_prefix
This callback is executed for directories. Its result determines if the traverser recurses into the directory or not. The default is
to always recurse into all directories. The callback is invoked with a single argument, the absolute path of the directory, and has
to return a boolean value, True when the directory passes the filter, and False if not.
-filter command_prefix
This callback is executed for all paths. Its result determines if the current path is a valid result, and returned by next. The
default is to accept all paths as valid. The callback is invoked with a single argument, the absolute path to check, and has to
return a boolean value, True when the path passes the filter, and False if not.
-errorcmd command_prefix
This callback is executed for all paths the traverser has trouble with. Like being unable to change into them, get their status,
etc. The default is to ignore any such problems. The callback is invoked with a two arguments, the absolute path for which the error
occured, and the error message. Errors thrown by the filter callbacks are handled through this callback too. Errors thrown by the
error callback itself are not caught and ignored, but allowed to pass to the caller, i.e. however invoked the next. Any other
results from the callback are ignored.
BUGS, IDEAS, FEEDBACK
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category fileutil
of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for
either package and/or documentation.
KEYWORDS
directory traversal, traversal
fileutil 0.4 fileutil_traverse(n)