Solved

unix2dos for SFTP

Posted on 2011-02-18
7
1,044 Views
Last Modified: 2012-05-11
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
Comment
Question by:coimbatore123
  • 3
  • 3
7 Comments
 
LVL 10

Expert Comment

by:APNFSSC
ID: 34930096
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
 

Author Comment

by:coimbatore123
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.

Thanks
0
 
LVL 10

Expert Comment

by:APNFSSC
ID: 34930221
what operating system and version and arch are you using?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 10

Accepted Solution

by:
APNFSSC earned 500 total points
ID: 34930283
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
 

Author Comment

by:coimbatore123
ID: 34930288
Pls see below:

SunOS <server_name> 5.10 Generic_142901-12 i86pc i386 i86pc


Thanks
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 34936981
can you share your command / script?
0
 

Author Closing Comment

by:coimbatore123
ID: 34951510
Thank you !!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now