Sponsored Content
Full Discussion: Ux2dos script
Operating Systems HP-UX Ux2dos script Post 302989505 by Peasant on Friday 13th of January 2017 10:27:02 AM
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 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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
UFL-CONVERT(1)						      General Commands Manual						    UFL-CONVERT(1)

NAME
ufl-convert - Convert a .ufl file to some other format. SYNOPSIS
ufl-convert [OPTIONS] input.ufl OPTIONS
-h, --help Display help text and exit. -o OUTPUTDIR, --outputdir=OUTPUTDIR Output directory. -i INPUTDIR, --inputdir=INPUTDIR Output directory. -c COMPILE, --compile=COMPILE 'Compile' forms: apply expression transformations like in a quadrature based form compilation. -f FORMAT, --format=FORMAT Rendering format (str, repr, tree, dot, latex). -t FILETYPE, --filetype=FILETYPE Output file type (txt, py, dot, tex, ps, pdf, png). -s SHOW, --show=SHOW Open in an external viewer. EXAMPLES
ufl-convert -omydir -iyourdir -c -f -tpdf -s mass.ufl BUGS
Send comments, questions, bug reports etc. to ufl@lists.launchpad.net. LICENSE
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as pub- lished by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. AUTHOR
Martin Sandve Alnaes <martinal@simula.no> This manual page was written by Johannes Ring <johannr@simula.no>. UFL-CONVERT(1)
All times are GMT -4. The time now is 06:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy