ksh - find command with 2 actions attached and error logging


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh - find command with 2 actions attached and error logging
# 1  
Old 04-12-2012
ksh - find command with 2 actions attached and error logging

Hi there,

I'm encountering problems on an AIX system when using following in my script.

Code:
   find . -name *.edi -type f  -exec sh -c 'scp {} $user@$server:$path || exit 5; mv {} $sent || exit 7' \;


the error i get is following

find: 0652-018 An expression term lacks a required parameter.

i did some testing and appearantly this the problem. However i don't see how else i can do this :s (creating a for loop does not work as there are 2 many files (+10000)
Code:
-exec sh -c '...'

thx in advance for the help.
# 2  
Old 04-12-2012
Could this help you ?

Code:
 
find . -name *.edi -type f  | xargs -I {} scp {} $user@$server:$path

# 3  
Old 04-12-2012
Quote:
Originally Posted by pravin27
Could this help you ?

Code:
 
find . -name *.edi -type f  | xargs -I {} scp {} $user@$server:$path

this would be perfect if not for the move i also need to execute. Could i get 2 commands after the | ?
because it is very important that the mv is executed directly after the scp. (also the exit codes are important to us)
# 4  
Old 04-12-2012
Try...
Code:
find . -name '*.edi' -type f | while read f; do scp $f $user@$server:$path || exit 5 ; mv $f $sent || exit 7 ; done

This User Gave Thanks to Ygor For This Post:
# 5  
Old 04-12-2012
Quote:
Originally Posted by Ygor
Try...
Code:
find . -name '*.edi' -type f | while read f; do scp $f $user@$server:$path || exit 5 ; mv $f $sent || exit 7 ; done

did anyone tell you you rock. Because you do.
It looks like this solves all the problems i encountered before.
I can go on to error testing now, but i'm quite confident it will work.

thanks again.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

ksh Logging

Hi, I want to run my script and want to ensure it captures all logging. For e.g I got this from another forum # Redirect the current stderr into stdout exec 2>&1 # Redirect the current stdout into the log file exec 1>timer_log.log The script will print stderr onto the putty terminal... (4 Replies)
Discussion started by: aixkidbee
4 Replies

2. Shell Programming and Scripting

ksh script find command not printing any results

Hello, Hitting a wall on this one. When at the command prompt it works fine: # find /home/testuser -name 'PAINT*canvasON.txt' /home/testuser/PAINT_canvasON.txt # pwd /home/testuser # ls -l PAINT*canvasON.txt -rw-r--r-- 1 root user 23 Feb 07 02:58 PAINT_canvasON.txt... (2 Replies)
Discussion started by: seekryts15
2 Replies

3. Shell Programming and Scripting

find command to move the files to other folder - ksh 88

Hi , I've learnt that the following command will remove the files from the given folder for given no.of days find /home/etc -type f -atime -10 -exec rm -f {} \; But how can I change the above command that will move the files to another specified directory instead of removing the... (1 Reply)
Discussion started by: smile689
1 Replies

4. Shell Programming and Scripting

Regular Expression in Find command [KSH]

Hello, I am trying to use regex wtih find command in KSH. For some reason it is not working as expected. Input: comm_000_abc_0102.c comm_000_abc.c 456_000_abc_1212.cpp 456_000_abc_.cpp Expected Output: comm_000_abc_0102.c kkm_000_abc_8888.cpp (Basically I want to find all... (6 Replies)
Discussion started by: vinay4889
6 Replies

5. Shell Programming and Scripting

Problem with find command at ksh

Hi! I made a shell script which is offering menu choice. I made it on RHEL & then with little bit changes I was able to run successfully on AIX/ksh. Script is working fine with no issues other than a little one i.e., There is one choice in which I can list out and delete some files from a... (10 Replies)
Discussion started by: sukhdip
10 Replies

6. Shell Programming and Scripting

problems with ksh array and find command

set -A allfiles `find $usrhtml -type f` i am trying to populate this array with the find command. It works fine when find is looking through a single directory but when i add a new subdirectory the files in the subdirectory get duplicated. Can anyone help me and fix this so each files in... (1 Reply)
Discussion started by: bjhum33
1 Replies

7. Shell Programming and Scripting

Help - Using Find command on dynamic files on KSH

Hi Forum. When I run the following find command, I get the desired results: find . \( -name a.out -o -name '*.o' -o -name 'core' \) -type f -ls I want for my script to dynamically calculate and assign a variable var1 to contain all the files that I want to search instead of hard-coding. ... (2 Replies)
Discussion started by: pchang
2 Replies

8. Shell Programming and Scripting

Problem with embedded FTP command in Ksh - System Cannot find the specified path.

I have the following FTP embedded in a Ksh script on AIX 5.3 ftp -n <<WHATEVER open 10.101.26.218 user hcistats ******* ascii put $thupdatefile put $thcollectfile quit WHATEVER Here is what my script returns: ... (3 Replies)
Discussion started by: troym72
3 Replies

9. UNIX for Advanced & Expert Users

find command from shell scipt (ksh) problem

Hi experts, I have a simple shell script as follows. #!/bin/ksh FIND_STRING="\( -name 'testfile*.Z' -o -name 'DUMMY_*' \) " find /tmp -type f $FIND_STRING -print When I run this with ksh -x testscript, I get the following output. + FIND_STRING=\( -name 'testfile*.Z' -o -name... (6 Replies)
Discussion started by: kodermanna
6 Replies

10. Solaris

Tracing a user and logging his actions

Dear All, I want to enable the tracing for a user and logging all things he do in a log file.......... Thaaanks (2 Replies)
Discussion started by: adel8483
2 Replies
Login or Register to Ask a Question