[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1069
  • Last Modified:

unix2dos for SFTP

Hi,

I have several files on a unix server that need to be sent to a windows server. via SFTP. If I am sending one file I can hardcode unix2dos command in the script. But since I have several files,do you know how I can do this in a script ?

P:S. SFTP connection has been established.

Please advise.

Thank you !
0
coimbatore123
Asked:
coimbatore123
  • 3
  • 3
1 Solution
 
APNFSSCCommented:
if all the files are in the same folder then you can use a wild card to convert them

example:

Files

/tmp/test1.txt
/tmp/test2.txt

Running the following will convert both files

unix2dos /tmp/test*.txt

0
 
coimbatore123Author Commented:
Tried this: unix2dos X*

But doesnt work:

user@server> unix2dos X*
usage: unix2dos [ -ascii ] [ -iso ] [ -7 ] [ originalfile [ convertedfile ] ]


Below are the files:
-rw-rw-r--   1 trtsftp  impact       558 Feb 17 22:36 XEDPRT
-rw-rw-r--   1 trtsftp  impact       558 Feb 17 22:37 XEPRNT
-rw-rw-r--   1 trtsftp  impact       828 Feb 17 22:37 XUPRNT

Please advise.

Thanks
0
 
APNFSSCCommented:
what operating system and version and arch are you using?
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
APNFSSCCommented:
Hi,

See attached code below.

You need to change the folder variable from /tmp to what ever you need it to be and also the X* to be what you would like it to be.

This would either to into an existing shell script or into it's how shell script.

 
#!/bin/sh
folder="/tmp"
for i in `ls "$folder"/X*`; do
unix2dos "$folder"/$i "$folder"/$i.tmp
mv "$folder"/$i.tmp "$folder"/$i
done

Open in new window

0
 
coimbatore123Author Commented:
Pls see below:

SunOS <server_name> 5.10 Generic_142901-12 i86pc i386 i86pc


Thanks
0
 
omarfaridCommented:
can you share your command / script?
0
 
coimbatore123Author Commented:
Thank you !!!
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now