Sponsored Content
Full Discussion: Ux2dos script
Operating Systems HP-UX Ux2dos script Post 302989955 by lcclaj0 on Friday 20th of January 2017 04:28:14 AM
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
 

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
libguestfs-make-fixed-appliance(1)			      Virtualization Support				libguestfs-make-fixed-appliance(1)

NAME
libguestfs-make-fixed-appliance - Make a "fixed appliance" for libguestfs SYNOPSIS
libguestfs-make-fixed-appliance [--options] OUTPUTDIR libguestfs-make-fixed-appliance [--options] --xz DESCRIPTION
libguestfs-make-fixed-appliance lets you make a pre-built binary appliance for libguestfs. Note that ordinary users should not need to run this tool. Some reasons why you might want to use this include: o You want to make a self-contained libguestfs appliance that can be copied to another machine or platform that doesn't support supermin(8). o You have multiple users on the same machine and want to avoid the storage duplication and start-up overhead of having multiple cached copies of the appliance. o You want to have very predictable performance from libguestfs (see guestfs-performance(1)). For deeper understanding of why you might need this tool, read the section "FIXED APPLIANCE" below. Instead of running this tool, you can download fixed appliances from http://libguestfs.org/download/binaries/appliance/. These appliances were made using this tool. There are two ways to use this tool. o Specify an output directory, for example: libguestfs-make-fixed-appliance /usr/local/lib/guestfs/appliance The output directory is created if it does not exist. Four files are created in this directory: <OUTPUTDIR>/kernel <OUTPUTDIR>/initrd <OUTPUTDIR>/root <OUTPUTDIR>/README.fixed Note that "OUTPUTDIR/root" is a sparse file, so take care when copying it. You can then run libguestfs (possibly after copying this directory to another machine) by setting the environment variable LIBGUESTFS_PATH to "OUTPUTDIR". o The alternative method is to use the --xz option to create a compressed tarball: libguestfs-make-fixed-appliance --xz This creates a tarball in the current directory called: appliance-<VERSION>.tar.xz (where "VERSION" is the version of libguestfs). The tarball contains the four files: appliance/kernel appliance/initrd appliance/root appliance/README.fixed Note that "appliance/root" is a sparse file, so take care when copying it. OPTIONS
--help Display short usage information and exit. -V --version Display the version number and exit. --xz Instead of creating the appliance in an output directory, create a compressed tarball of the appliance in the current directory called "appliance-VERSION.tar.xz" where "VERSION" is the version of libguestfs. Using --xz can take some time. If working normally, the tool is completely silent when it is running. FIXED APPLIANCE
When libguestfs (or libguestfs tools) are run, they search a path looking for an appliance. The path is built into libguestfs, or can be set using the "LIBGUESTFS_PATH" environment variable. Normally a supermin appliance is located on this path (see "SUPERMIN APPLIANCE" in supermin(8)). libguestfs reconstructs this into a full appliance by running supermin-helper(8). However, a simpler "fixed appliance" can also be used. libguestfs detects this by looking for a directory on the path containing four files called "kernel", "initrd", "root" and "README.fixed" (note the "README.fixed" file must be present as well). If the fixed appliance is found, libguestfs skips supermin entirely and just runs qemu with the kernel, initrd and root disk from the fixed appliance. Thus the fixed appliance can be used when a platform or Linux distro does not support supermin. You build the fixed appliance on a platform that does support supermin, and copy it over, and use that to run libguestfs. LICENSING
The fixed appliance is a complete Linux binary distro. If you distribute it, you may need to distribute corresponding source files to remain in legal compliance with the licenses of the software in the appliance (such as the GNU General Public License). EXIT STATUS
libguestfs-make-fixed-appliance returns 0 if the appliance was built without errors. ENVIRONMENT VARIABLES
For the full list of environment variables which may affect libguestfs, please see the guestfs(3) manual page. SEE ALSO
guestfs(3), supermin(8), supermin-helper(8), xz(1), http://libguestfs.org/, http://qemu.org/. AUTHORS
Richard W.M. Jones ("rjones at redhat dot com") COPYRIGHT
Copyright (C) 2009-2013 Red Hat Inc. LICENSE
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 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 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BUGS
To get a list of bugs against libguestfs, use this link: https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools To report a new bug against libguestfs, use this link: https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools When reporting a bug, please supply: o The version of libguestfs. o Where you got libguestfs (eg. which Linux distro, compiled from source, etc) o Describe the bug accurately and give a way to reproduce it. o Run libguestfs-test-tool(1) and paste the complete, unedited output into the bug report. libguestfs-1.22.6 2013-08-24 libguestfs-make-fixed-appliance(1)
All times are GMT -4. The time now is 06:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy