Sponsored Content
Top Forums Shell Programming and Scripting How to auto correct a failing command? Post 302989990 by Corona688 on Friday 20th of January 2017 10:38:48 AM
Old 01-20-2017
He hasn't said so explicitly, but I've gained the impression that mohtashims has been required to maintain and port a lot of shell scripts not all his own devising, and hopes for cookie-cutter solutions for scripts written using non-portable options.

There a few strategies you can try.
  1. Substituting different commands on different systems.
  2. Building your own substitutes for every troublesome command.
  3. Re-factoring the scripts to use actually portable options.

Solution #1 obviously looks easier and more attractive, since hypothetically it can be done with just a "header" section and few to no changes to large amounts of code you may not necessarily understand. But if it really was better, you would have solved your problems months ago. You must be dealing with a large number of very different systems, as you're still finding and plugging hole after hole, and will continue to do so for a long time. What will you do when you hit one which doesn't have GNU extensions available?

Solution #2 is a big job. I've spent large amounts of time duplicating one command.

Solution #3 unfortunately means having to understand what grep -o actually means, so as to replace it. You may want to break it down and test commands individually rather than fighting it as one gigantic block of code.

My last comment: This is what happens when you try and detect and compensate for every difference between systems:
Image
That's 800 kilobytes of ad-hoc corrections per decade, more or less.
 

10 More Discussions You Might Find Interesting

1. HP-UX

dd command failing

I am new to HP-UX. I have an 8GB drive that is my root drive, contained in a Volume Group. I would like to clone that drive to another drive, which is 18.4GB. The other drive is not in a volume group. I am using this simple command:# dd if=/dev/dsk/c0t6d0 of=/dev/dsk/c0t5d0The command... (4 Replies)
Discussion started by: emsecrist
4 Replies

2. UNIX for Dummies Questions & Answers

Is this grep command correct?

Hi I need to know if I have got the following grep command correct. I wanted to find from myfile.txt all signed real numbers (e.g. +5.0, -78, but not 5.0, 5 are not). I have thought about it and decided it was this: grep '' myfile.txt but I was wondering if this was correct. If... (2 Replies)
Discussion started by: rushhour
2 Replies

3. Shell Programming and Scripting

tty command failing

We have script like this in the .bash_profile.. #-# determine if session is interactive or in background if ]; then while true; do read -p "Do you wish to load profile yes or no?" yn case $yn in * ) source /opt/oracle/.profile; break;; * ) break;; *... (2 Replies)
Discussion started by: talashil
2 Replies

4. Shell Programming and Scripting

For loop failing cd command

Hi guys, i've wrote the following loop; for i in `ls` do cd $i/host cat "xxxx.txt" |grep "yyyy" >> zzzz.txt done I have a set of folder with different name and i need to extract a value from a file contained in the host subfolder ( that is present in each folder). When i run... (4 Replies)
Discussion started by: cecco16
4 Replies

5. UNIX for Advanced & Expert Users

I was trying this command...am I going correct? other there is better way

I was trying to copy all debs from apt cache to some storage location and I was taking this approach... /var/cache/apt/archives# ls -1 | grep -v jdownloader | fgrep .deb | xargs cp /media/eshant/L-STORE/Softwares/openjdk/an error bla_bla.deb is a not directory stalled me Suggestions please... (9 Replies)
Discussion started by: ezee
9 Replies

6. Post Here to Contact Site Administrators and Moderators

Auto correct a csv file using UNIX shell script.

Hi All, There are list of 4-5 .csv files which has 12 columns.In some cases one of the record is split into 2 records. What needs to be done is this split record has to be auto corrected and placed in the csv file. Eg: Let us consider sample.csv file and in normal conditions the file... (1 Reply)
Discussion started by: karthik_ak
1 Replies

7. Shell Programming and Scripting

Auto correct a csv file using UNIX shell script.

Hi All, There are list of 4-5 .csv files which has 12 columns.In some cases one of the record is split into 2 records. What needs to be done is this split record has to be auto corrected and placed in the csv file. Eg: Let us consider sample.csv file and in normal conditions the file would... (40 Replies)
Discussion started by: karthik_ak
40 Replies

8. UNIX for Dummies Questions & Answers

While trying to load .so file manually using command its failing

Hi all, I am newbie to linux environment. I was trying to run an .so file manually which in turn call a method in bin folder. Command given, XXX_MODULES=libxxx.so /opt/servicename/bin/methodname -Le -c /opt/servicename/etc/methodname/methodname.conf -n -C -t -m "" When i tried to... (1 Reply)
Discussion started by: sharathpadman
1 Replies

9. UNIX for Advanced & Expert Users

While trying to load .so file manually using command its failing

Hi all, I am newbie to linux environment. I was trying to run an .so file manually which in turn call a method in bin folder. Command given, XXX_MODULES=libxxx.so /opt/servicename/bin/methodname -Le -c /opt/servicename/etc/methodname/methodname.conf -n -C -t -m "" When i tried to execute... (1 Reply)
Discussion started by: sharathpadman
1 Replies

10. Shell Programming and Scripting

LS command does not list the correct file

Hi, I am logged into as root & inside the home directory of another user. ls -a # ls -laq total 44 drwx------ 4 user1 adm 4096 Nov 23 05:10 . drwxr-xr-x. 12 root root 4096 Nov 22 13:05 .. -rw-r--r-- 1 user1 adm 18 Nov 22 13:05 .bash_logout -rw-r--r-- 1 user1 adm 193 Nov... (2 Replies)
Discussion started by: mohtashims
2 Replies
img-tiff(n)															       img-tiff(n)

NAME
img-tiff - Img, Tagged Image File Format (tiff) SYNOPSIS
package require Tk package require img::tiff ?1.3? image create photo ?name? ?options? DESCRIPTION
The package img::tiff is a sub-package of Img. It can be loaded as a part of the complete Img support, via package require Img, or on its own, via package require img::tiff. Like all packages of Img it does not provide new commands, but extends the existing Tk command image so that it supports files containing raster images in the Tagged Image File Format (tiff). More specifically img::tiff extends Tk's photo image type. The name of the new format handler is tiff. This handler provides new additional configuration options. See section TIFF OPTIONS for more detailed explanations. All of the above means that in a call like image create photo ?name? ?options? [1] Image data in tiff format (options -data and -file) is detected automatically. [2] The format name tiff is recognized by the option -format. In addition the value for the option is treated as list and may contain any of the special options listed in section TIFF OPTIONS. TIFF OPTIONS
The handler provides two options to influence the writing of a TIFF image. There are no options to influence the reader. -compression type This option specifies the type of compression to use when writing TIFF data. It has to be one of none, jpeg, packbits, or deflate. The default is none. -byteorder type This option specifies the byteorder to use when writing TIFF data. It has to be one of bigendian, littleendian, network, smallen- dian, or the empty string. The default is the empty string. The values bigendian and network are aliases of each other, as are littleendian and smallendian. SEE ALSO
img-bmp, img-gif, img-ico, img-intro, img-jpeg, img-pcx, img-pixmap, img-png, img-ppm, img-ps, img-sgi, img-sun, img-tga, img-tiff, img- window, img-xbm, img-xpm KEYWORDS
image handling, tiff, tk COPYRIGHT
Copyright (c) 1995-2003 Jan Nijtmans <nijtmans@users.sourceforge.com> Img 1.3 img-tiff(n)
All times are GMT -4. The time now is 03:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy