unix2dos for SFTP

Posted on 2011-02-18
Medium Priority
Last Modified: 2012-05-11

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 !
Question by:coimbatore123
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 10

Expert Comment

ID: 34930096
if all the files are in the same folder then you can use a wild card to convert them




Running the following will convert both files

unix2dos /tmp/test*.txt


Author Comment

ID: 34930213
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.

LVL 10

Expert Comment

ID: 34930221
what operating system and version and arch are you using?
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

LVL 10

Accepted Solution

APNFSSC earned 2000 total points
ID: 34930283

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.

for i in `ls "$folder"/X*`; do
unix2dos "$folder"/$i "$folder"/$i.tmp
mv "$folder"/$i.tmp "$folder"/$i

Open in new window


Author Comment

ID: 34930288
Pls see below:

SunOS <server_name> 5.10 Generic_142901-12 i86pc i386 i86pc

LVL 40

Expert Comment

ID: 34936981
can you share your command / script?

Author Closing Comment

ID: 34951510
Thank you !!!

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question