Ux2dos script


 
Thread Tools Search this Thread
Operating Systems HP-UX Ux2dos script
# 1  
Old 01-13-2017
Ux2dos script

Hi all,
Does anyone know how to convert a good few files in a particular directory (unix) to dos files and place them in another directory?
I know this can be done with ux2dos but I am trying to come up with a shell script to do so
# 2  
Old 01-13-2017
Dear lcclaj0,

I have a few to questions pose in response first:-
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.


We're all here to learn and getting the relevant information will help us all.
# 3  
Old 01-13-2017
Quote:
Originally Posted by rbatte1
Dear lcclaj0,

I have a few to questions pose in response first:-
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.


We're all here to learn and getting the relevant information will help us all.

HPUX v11.3

I just need a good script that can do the above as I am not the best at shell scripting
# 4  
Old 01-13-2017
We are all here to learn from each other, not just to be a free script writing service.

Whilst I would be happy to help (and the only possible payment would be you pressing the SmilieThanks button) you need to show us what you have tried so far along with the errors so that we can suggest improvements.

There is no point in spoon feeding you an answer that you do not understand and cannot support when you need to adjust it in the future.


If you can't be bothered to try first (no matter how badly wrong it goes) and show us the attempt and the errors, then .........
This User Gave Thanks to rbatte1 For This Post:
# 5  
Old 01-13-2017
i'm willing to provide a small script for you this time, once and explain it as much as i can.

Hopefully we shall see in the future will user lcclaj0 ask simple question again without any tries, but lets assume he is new in scripting and is looking for a simple example.

Code:
INPUTDIR=/directorywithunixfiles
OUTPUTDIR=/directoryforoutput
[ -d $OUTPUTDIR ] || exit 1 # script will exit if $OUTPUTDIR is not a directory.
cd $INPUTDIR || exit 1 # script will exit if it's unable to change directory to $INPUTDIR, additionally it will print the cd command error on stderr
for i in * # for everything in $INPUTDIR 
do
   if [ -f "$i" ]; then # if it's a file use ux2dos utility on it, otherwise silently ignore.
   ux2dos "$i" > "${OUTPUTDIR}"/"$i"
   fi
done
cd - # return to directory the script has been issued from.

Directory /directoryforoutput (destination) will contain converted files with /directorywithunix (source) will contain original files, uneffected by operation (exception being modifed atime -access time, if used on filesystem, by default vxfs - yes.)

This is sample shell script with basic error handling.

Shell commands and constructs used :

1. Variable declaration (directories used INPUTDIR OUTPUTDIR)
2. Conditional operator ( || )
3. Test constructs ([ .. ]) # man test
4. for loop to iterate over the directory contents
5. ux2dos utility to convert format.

Script will not go into subdirectories or process files with dots in names e.g .config

Hope that helps.
Best regards
Peasant.
This User Gave Thanks to Peasant For This Post:
# 6  
Old 01-13-2017
I will try this.. Thanks Peasant and correct I am a beginner at shell scripting..
# 7  
Old 01-20-2017
Quote:
Originally Posted by Peasant
i'm willing to provide a small script for you this time, once and explain it as much as i can.

Hopefully we shall see in the future will user lcclaj0 ask simple question again without any tries, but lets assume he is new in scripting and is looking for a simple example.

Code:
INPUTDIR=/directorywithunixfiles
OUTPUTDIR=/directoryforoutput
[ -d $OUTPUTDIR ] || exit 1 # script will exit if $OUTPUTDIR is not a directory.
cd $INPUTDIR || exit 1 # script will exit if it's unable to change directory to $INPUTDIR, additionally it will print the cd command error on stderr
for i in * # for everything in $INPUTDIR 
do
   if [ -f "$i" ]; then # if it's a file use ux2dos utility on it, otherwise silently ignore.
   ux2dos "$i" > "${OUTPUTDIR}"/"$i"
   fi
done
cd - # return to directory the script has been issued from.

Directory /directoryforoutput (destination) will contain converted files with /directorywithunix (source) will contain original files, uneffected by operation (exception being modifed atime -access time, if used on filesystem, by default vxfs - yes.)

This is sample shell script with basic error handling.

Shell commands and constructs used :

1. Variable declaration (directories used INPUTDIR OUTPUTDIR)
2. Conditional operator ( || )
3. Test constructs ([ .. ]) # man test
4. for loop to iterate over the directory contents
5. ux2dos utility to convert format.

Script will not go into subdirectories or process files with dots in names e.g .config

Hope that helps.
Best regards
Peasant.


Hi all, so I tried with this script and share it to a directory shared by samba but when I go to open the file on my windows machine the file is still in unix format which is all over the place Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

3. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below. #masterscript.sh ./callingscript.sh echo $fileExist #callingscript.sh echo "The script is called"... (2 Replies)
Discussion started by: Raj Roy
2 Replies

4. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

5. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies

6. UNIX for Dummies Questions & Answers

ux2dos

I am trying to do a ux2dos to several files. Anyone know the syntax for that ?? Thanks Zapper (4 Replies)
Discussion started by: zapper222
4 Replies
Login or Register to Ask a Question