My script failed and can't fix it ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting My script failed and can't fix it ?
# 22  
Old 04-30-2013
you welcome as well dear , but now I have another issue I wanna log the output of every collected files but look like something went wrong , I feel that my error is hide in what follows:
  1. In ftp function I did not manage to control if file exist in my local directory then skipped (no need to collect it again , in order not to overwrite the collected one )
  2. " Move file1xxxx 20130428 " message from output log "20130428.log" is accumulated thus if "file1xxxx" was already organized in directory 20130428 & still in remote server when ftp works it will be collected & organized again (although I'm need for any clue to overcome this but no matter as the size of file has no changed ) but it will be added to 20130428.log as duplicated one & unfortunately I can't (sort, uniq) that log to skip any duplication , thanks for follow up
Code:
for file in * ; do
  dir=$( echo $file | cut -c1-8 )
    [ -d $dir ] || mkdir -p $dir
    echo "$dir was created "
    [ -f $file  ] && mv  $file  $dir
     echo "Move $file  $dir"    >>  /user/$dir.log
     sort -u  /user/$dir.log
done

# 23  
Old 04-30-2013
Quote:
I can't (sort, uniq) that log to skip any duplication
I edited the script some to show how to get rid of the duplication.
Code:
for file in * ; do
  dir=$( echo $file | cut -c1-8 )
  [ -d $dir ] || mkdir -p $dir
  echo "$dir was created"
  [ -f $file ] && mv $file $dir

  log=/user/$dir.log
  echo "Move $file $dir" >> $log
  sort -u $log > /tmp/temp.x
  mv /tmp/temp.x $log
done

This User Gave Thanks to hanson44 For This Post:
# 24  
Old 05-01-2013
thanks for your editing I'm going to test it soon but would like to know ? for how long the temp.x file will be in system till be deleted ? do you think my script was failed due to RAM issue or it was running so fast thus the system can not sort the files , is it possible to tell where is my fault ? really I like scripting but sometimes I do mistaken for easy thing , thank you again Smilie
/tmp/temp.x
# 25  
Old 05-01-2013
Quote:
how long the temp.x file will be in system till be deleted ?
It will be in the system very briefly. The mv command renames it to the name stored in $log variable, and then temp.x file is gone. Probably better to use $HOME/temp.x to be safer.

Quote:
is it possible to tell where is my fault ?
Yes, it is possible to tell. Your sort -u /user/$dir.log command was producing sorted output, but the sorted output was not getting saved. That was why I redirected the output to the temp.x file, and then used mv to overwrite the $log file, so the sorted output would get saved.

Anyway, see what happens, and if still a problem, repost the script and whatever error message happens.
# 26  
Old 05-02-2013
Smilie
It was really helpful to look at your post , it was successfully done , from now on I'm going to check what you are going to post , thanks a lot hanson44
# 27  
Old 05-03-2013
You are very welcome. I'm glad you were patient and it's working. Smilie
# 28  
Old 05-25-2013
run it every second by cron or whatever

I wanna do a little bit change on my whole script ( ftp and for loop ) since I tried to run it as cornjob but as you know it could not be run every 1 second, why I'm doing that because while I'm copying the files from remote server to my side another use his ftp session to cut the files thus I'm losing some of them, I'm thinking not to run my script as cronjob , do using one of the following then execute it directly in background to be able to connect that server and get the files every 1 second before cutting them by another user , am I right or not ?


Code:
while true 
do
ftp -in x,x,x,x  << ENDFTP
user username password
cd $ddir 
lcd $sdir 
bin 
prompt 
mget *.text 
bye 
ENDFTP
done

or

Code:
while true
do
ftp function I have
done


Last edited by arm; 05-25-2013 at 03:56 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Fix script to get missing information

Gents, Can you please help me to fix the following script in order to get complete data as desired. I am missing some data in output. the complete input file is attached. The script I am using is awk '{\ status=substr($0,91,2)\ ind=substr($0,26,1);\ ... (10 Replies)
Discussion started by: jiam912
10 Replies

2. UNIX for Dummies Questions & Answers

How to fix Python path for some script/app?

Hello, i have: # python -V Python 2.7.6 But original for my CentOS is 2.3 or 2.4 my python folder: /root/python2.7.6 (inside are folders like lib, include, bin, share) I launched app iotop: # iotop -od 6 Traceback (most recent call last): File "/usr/bin/iotop", line 16, in... (3 Replies)
Discussion started by: postcd
3 Replies

3. Shell Programming and Scripting

How to fix my IMDB Script

Hello, I am using IMDB bot file for my movie site.. But I get this message like this---Parse error: syntax error, unexpected end of file, expecting variable (T_VARIABLE) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN) in... (2 Replies)
Discussion started by: lg2013
2 Replies

4. UNIX for Dummies Questions & Answers

Please help to fix awk script

Good morning, fellows. I would need to ask for your help in editing my awk script. Here is the original version: BEGIN { printf ("CRYST1 200.000 200.000 200.000 90.00 90.00 90.00 P 1 1\n") maxatoms=1000 natom=0 found_struct = 0 found_bond = 0 } { if( NF == 5 ) { foundff=0 natom++... (9 Replies)
Discussion started by: snysmumrik
9 Replies

5. Windows & DOS: Issues & Discussions

Fix script error (%%n)

Hi, I'm currently tinkering with a script that uses the for command to process all *.gif files in the current folder. I marked the spot where it exits out with an error by adding a "pause" The error message given is: convert.exe: unable to open image `%x': No such file or directory @... (2 Replies)
Discussion started by: pasc
2 Replies

6. Shell Programming and Scripting

ksh script failed while using -x

Hi, I have a Kshell script that is failed if i am using the -x option. $ cat ListOfFiles.lst \+DATA_DM01/pudwh/datafile/dw_billing_tts_1 \+DATA_DM01/pudwh/datafile/dw_billing_tts_2 ... (2 Replies)
Discussion started by: yoavbe
2 Replies

7. Shell Programming and Scripting

AWK script getting failed

Hi All, Below is my code , In the code below the "If" condition is getting failed. I dont know what is getting wrong here , may be i can not use may logical operator at once or something else OR brackets under If condition are to be organised . Please help!! if ($11 == "0" &&... (1 Reply)
Discussion started by: unknown123
1 Replies

8. Shell Programming and Scripting

script for failed processes

I want to write a script that log all the failed processes and start the same process. For that I have already write a script that gives all the PID #!/bin/ksh pid= `ps -ef |grep "ov" |grep -v "grep"| awk '{print $2}'` echo $pid if ; then echo "process is running" else echo... (4 Replies)
Discussion started by: kumarabhi84
4 Replies

9. Shell Programming and Scripting

how to fix this awk script?

i have a log file while looks like this ++ user_a blabla blabla nas_b blabla user_d this is a user_a junk line another junk line user_c nas_m blabla ++ basically most of the lines contain a "user" keywords, and the rest of the lines do not have "user" at all. So I have the... (17 Replies)
Discussion started by: fedora
17 Replies

10. Shell Programming and Scripting

fix a problem in this script

z=9 i=0 h=02 min=55 while do cat /home/barmecha/test | grep $h:$min >> /home/barmecha/file1 min=`expr $min + 1` if ; then h=`expr $h + 1` fi i=`expr $i + 1` done i have a log file with time wise log in it, this script help me to pull out logs of the give time interval...but the... (8 Replies)
Discussion started by: abhishek27
8 Replies
Login or Register to Ask a Question