Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Issues in Csv file transfer copy from one dir to another Post 302945561 by phumaree on Sunday 31st of May 2015 09:37:53 AM
Old 05-31-2015
Quote:
Originally Posted by Don Cragun
What editor did you use when you modified this script to run on Widows? You might get output like this if some of the lines in the script are terminated by <carriage-return><newline> character pairs instead of the UNIX <newline> line terminators (without the <carriage-return>s)...

Show us the output from the command:
Code:
od -bc < pumelatxf.ksh

If you see \r as well as \n in that output, try running the command:
Code:
tr -d '\r' < pumelatxf.ksh > xyzzy && cp xyzzy pumelatxf.ksh && rm xyzzy

and, if that succeeds, try running it again with:
Code:
bash -xv pumelatxf.ksh

and show us the output that produces.
hi Don, here were the outputs (i am using crimson editor):
Code:
pumela@vampyrtest Non Production ~/pumela
$ od -bc < pumelatxf.ksh
0000000 043 041 057 142 151 156 057 153 163 150 012 144 151 162 061 075
          #   !   /   b   i   n   /   k   s   h  \n   d   i   r   1   =
0000020 042 057 150 157 155 145 057 165 163 145 162 057 160 165 155 145
          "   /   h   o   m   e   /   u   s   e   r   /   p   u   m   e
0000040 154 141 042 012 143 144 040 042 044 144 151 162 061 042 012 146
          l   a   "  \n   c   d       "   $   d   i   r   1   "  \n   f
0000060 157 162 040 163 162 143 144 040 151 156 040 057 150 157 155 145
          o   r       s   r   c   d       i   n       /   h   o   m   e
0000100 057 165 163 145 162 057 160 165 155 145 154 141 057 012 144 157
          /   u   s   e   r   /   p   u   m   e   l   a   /  \n   d   o
0000120 040 040 040 040 164 141 162 147 145 164 144 075 044 173 163 162
                          t   a   r   g   e   t   d   =   $   {   s   r
0000140 143 144 043 052 057 175 012 040 040 040 040 151 146 040 133 040
          c   d   #   *   /   }  \n                   i   f       [
0000160 041 040 055 144 040 042 044 163 162 143 144 042 040 135 040 174
          !       -   d       "   $   s   r   c   d   "       ]       |
0000200 174 040 133 040 041 040 055 144 040 042 044 164 141 162 147 145
          |       [       !       -   d       "   $   t   a   r   g   e
0000220 164 144 042 040 135 012 040 040 040 040 164 150 145 156 040 040
          t   d   "       ]  \n                   t   h   e   n
0000240 040 040 143 157 156 164 151 156 165 145 040 040 040 040 043 040
                  c   o   n   t   i   n   u   e                   #
0000260 123 157 165 162 143 145 040 157 162 040 164 141 162 147 145 164
          S   o   u   r   c   e       o   r       t   a   r   g   e   t
0000300 040 144 151 162 145 143 164 157 162 171 040 144 157 145 163 040
              d   i   r   e   c   t   o   r   y       d   o   e   s
0000320 156 157 164 040 145 170 151 163 164 056 012 040 040 040 040 146
          n   o   t       e   x   i   s   t   .  \n                   f
0000340 151 012 040 040 040 040 143 144 040 042 044 163 162 143 144 042
          i  \n                   c   d       "   $   s   r   c   d   "
0000360 040 076 040 057 150 157 155 145 057 165 163 145 162 057 160 165
              >       /   h   o   m   e   /   u   s   e   r   /   p   u
0000400 155 145 154 141 057 141 162 143 150 151 166 145 012 040 040 040
          m   e   l   a   /   a   r   c   h   i   v   e  \n
0000420 040 146 157 162 040 146 151 154 145 040 151 156 040 052 056 143
              f   o   r       f   i   l   e       i   n       *   .   c
0000440 163 166 012 040 040 040 040 144 157 040 040 040 040 151 146 040
          s   v  \n                   d   o                   i   f
0000460 133 040 042 044 146 151 154 145 042 040 075 040 047 052 056 143
          [       "   $   f   i   l   e   "       =       '   *   .   c
0000500 163 166 047 040 135 012 040 040 040 040 040 040 040 040 164 150
          s   v   '       ]  \n                                   t   h
0000520 145 156 040 040 040 040 142 162 145 141 153 040 040 040 040 043
          e   n                   b   r   e   a   k                   #
0000540 040 116 157 040 052 056 143 163 166 040 146 151 154 145 163 040
              N   o       *   .   c   s   v       f   i   l   e   s
0000560 164 157 040 155 157 166 145 040 151 156 040 164 150 151 163 040
          t   o       m   o   v   e       i   n       t   h   i   s
0000600 144 151 162 145 143 164 157 162 171 012 040 040 040 040 040 040
          d   i   r   e   c   t   o   r   y  \n
0000620 040 040 145 154 163 145 040 040 040 040 145 143 150 157 040 155
                  e   l   s   e                   e   c   h   o       m
0000640 166 040 052 056 143 163 166 040 042 044 144 151 162 061 057 044
          v       *   .   c   s   v       "   $   d   i   r   1   /   $
0000660 164 141 162 147 145 164 144 042 040 040 040 040 043 040 115 157
          t   a   r   g   e   t   d   "                   #       M   o
0000700 166 145 040 164 150 145 040 146 151 154 145 163 012 040 040 040
          v   e       t   h   e       f   i   l   e   s  \n
0000720 040 040 040 040 040 040 040 040 040 142 162 145 141 153 012 040
                                              b   r   e   a   k  \n
0000740 040 040 040 040 040 040 040 146 151 012 040 040 040 040 144 157
                                      f   i  \n                   d   o
0000760 156 145 012 040 040 040 040 143 144 040 055 040 076 040 057 150
          n   e  \n                   c   d       -       >       /   h
0001000 157 155 145 057 165 163 145 162 057 160 165 155 145 154 141 057
          o   m   e   /   u   s   e   r   /   p   u   m   e   l   a   /
0001020 141 162 143 150 151 166 145 012 144 157 156 145
          a   r   c   h   i   v   e  \n   d   o   n   e
0001034

Code:
pumela@vampyrtest Non Production ~/pumela
$ tr -d '\r' < pumelatxf.ksh > xyzzy && cp xyzzy pumelatxf.ksh && rm xyzzy

Code:
pumela@vampyrtest Non Production ~/pumela
$ bash -xv pumelatxf.ksh
#!/bin/ksh
dir1="/home/user/pumela"
+ dir1=/home/user/pumela
cd "$dir1"
+ cd /home/user/pumela
for srcd in /home/user/pumela/
do    targetd=${srcd#*/}
    if [ ! -d "$srcd" ] || [ ! -d "$targetd" ]
    then    continue    # Source or target directory does not exist.
    fi
    cd "$srcd" > /home/user/pumela/archive
    for file in *.csv
    do    if [ "$file" = '*.csv' ]
        then    break    # No *.csv files to move in this directory
        else    echo mv *.csv "$dir1/$targetd"    # Move the files
            break
        fi
    done
    cd - > /home/user/pumela/archive
done
+ for srcd in /home/user/pumela/
+ targetd=home/user/pumela/
+ '[' '!' -d /home/user/pumela/ ']'
+ '[' '!' -d home/user/pumela/ ']'
+ continue

pumela@vampyrtest Non Production ~/pumela
$


Last edited by phumaree; 05-31-2015 at 10:39 AM.. Reason: to add editor name
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to copy a file to a directory ,where file and dir are sent as args to a function?

Hi all, I wanted to know how i can copy a file to a directory and then verify if that file is completely copied or not? Now the issues here is that the dir and the source file are to be sent as arguments to a function( this function should actually copy the files to a dir, then check if its... (0 Replies)
Discussion started by: wrapster
0 Replies

2. UNIX and Linux Applications

CPIO Problem, copy to the root dir / instead of current dir

HI all, I got a CPIO archive that contains a unix filesystem that I try to extract, but it extract to the root dir / unstead of current dir, and happily it detects my file are newer otherwise it would have overwrited my system's file! I tried all these commands cpio -i --make-directories <... (2 Replies)
Discussion started by: nekkro-kvlt
2 Replies

3. UNIX for Dummies Questions & Answers

File Transfer issues SUN - > AIX

Hi, I'm puzzled at how this could be. I'm trying to transfer some files from an Sun box to an AIX box via FTP. The file transfer goes fine until it reaches a file of about 150k then times out and fails. The FTP Does not seem to be able to transfer files of more than 150k! However, I can... (5 Replies)
Discussion started by: bbbngowc
5 Replies

4. UNIX for Dummies Questions & Answers

Copy dir/file from one place to another.

Hello all. I'm not getting the hang of Paths. I have a dir w/files that I want to copy to another dir. Right now I am in the "source" directory. I want to copy it to Ch7. "cp -r source Ch7". Ch7 was already created. 1st msg.: cannot stat `source`: No such file or dir. I typed pwd & got... (3 Replies)
Discussion started by: Ccccc
3 Replies

5. Shell Programming and Scripting

Copy Files to Dir and Check If File Exists

Hi everyone. I am trying to write a bash script that will copy files from one directory to another but I need to be able to check the directory that I'm copying the files to and see if the file already exists. If it does I need to add a number at the end of the copied file. Thanks for your help. (3 Replies)
Discussion started by: snag49ers
3 Replies

6. Shell Programming and Scripting

Copy files from input file with dir structure

hi, I want to copy files from source directory based on input file (or output of previous command) and i want to have the SAME DIRECTORY STRUCTURE. Note that i will have other files and directories which i dont want to copy to destination. For example, dir source has following content:... (22 Replies)
Discussion started by: dragon.1431
22 Replies

7. Shell Programming and Scripting

check if some file is in copy process, then transfer it

my user copy large files, and it's take 10min for file to be copied to the server (/tmp/user/ files/), if in the meantime start my scheduled script, then it will copy a part of some file to server1 my idea is to check the file size twice in a short period (1-2 seconds) of time, then compare, if... (5 Replies)
Discussion started by: waso
5 Replies

8. Shell Programming and Scripting

Copy files and subdirs from dir to a new dir

Hello Comunity I am trying to make a bash shell script that it copies files and subdirs(with files) to a new dir. I would like the dest_dir to contain only subdirectories with files not other subdirs inside. it called : cpflatdir src_dir dest_dir Pleaze help me! Thank you in... (2 Replies)
Discussion started by: BTKBaaMMM
2 Replies

9. UNIX for Advanced & Expert Users

Secure Copy - File Transfer between 2 server

Using RCP command we can transfer file from one server to another server. While transferring we can rename the file also e.g. File name = FILE123.txt (lying on Source server = oldserver) Target Server Name = newyour Renamed File = FILE456.txt rcp FILE123.txt newyour:./FILE456.txt... (1 Reply)
Discussion started by: Pash
1 Replies

10. Shell Programming and Scripting

Switching between directories and mkdir/copy dir/file

I was trying to copy the files inside the path /home/user/check/Q1/dir/folder1/expected/n/a1.out1 and a1.out2 and a1.out3 to /home/user/check/Q2/dir/folder1/expected/n/ if n directory is not present at Q2/dir/folder1/expected/ then directory should be created first. And, script follow the... (5 Replies)
Discussion started by: Mannu2525
5 Replies
All times are GMT -4. The time now is 10:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy