Script for cygwin, HDF-EOS for converting HDF to TIF


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script for cygwin, HDF-EOS for converting HDF to TIF
Prev   Next
# 5  
Old 09-12-2010
Some parts of your code expands words when a variable or a command exansion expands contents with spaces

Code:
	for i in  `find .` ; do # problem if a line has a space

	............. $i ......................

	........................................... $i.prm
	......................................... $i.prm
	fi
	done

Since sh really have some difficulties when separated lines in output, I suggest using bash instead:
Code:
#!/bin/bash

# in this script it is assumed that HEG executables are in 
# "/home/user/heg2.9/HEG/bin" directory, and that we are 
# processing a file that contains GRIDS. For processing files
# that contain SWATH use "swtif" instead of "resample"

while read I; do
	hdffile=$(file "$I" | awk '{print 1.58€}')

	if [[ "$hdffile" = "Hierarchical" ]]; then
		sed "s/input/$I/" heg_template_unix.prm > "$I.prm"
	fi
done < <(find .)

P.S. for X in $VAR or `command`; do ...; done is really not a good idea since it depends on IFS and is what's always bugging scripts basing on old shells.

Yes changing IFS to '\n' may be a solution but it still won't be enough if the contents contain glob characters especially [ and ] which are also valid characters of a filename.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can i get variable value inside << EOS?

Hi, Below is my code: user="wluser" password="welcom123" ip=$1 expect << 'EOS' spawn sftp ${user}@${ip}:/ expect "Password:" send "${pass}\n" expect "sftp>" send "get *date.csv\n" expect "sftp>" send "bye\n" EOS (4 Replies)
Discussion started by: mohtashims
4 Replies

2. Shell Programming and Scripting

Cygwin shell script

I have a file with below format : 2013-05-20 hello has done 2013-05-20 hi 000abc abc 2013-05-21 thank you I want the out put to be like this : 2013-05-20 hello has done 2013-05-20 hi 000abc abc 2013-05-21 thank you What I could think of is something like this : cat... (7 Replies)
Discussion started by: Sparta
7 Replies

3. Programming

Script for creating a directory & move the .tif files in it.

Hi Team, I have thousands of TIF files which are converted from PDF. Below is a sample of it. LH9406_BLANCARAMOS_2012041812103210320001.tif LH9406_BLANCARAMOS_2012041812103210320002.tif LH9406_BLANCARAMOS_2012041812103210320003.tif LH9411_ANGENIAHUTCHINSON_2012041812102510250001.tif... (9 Replies)
Discussion started by: paragnehete
9 Replies

4. Shell Programming and Scripting

opening new instance of cygwin from withing cygwin

I'm using cygwin on win7, What I would like to do is something like this: cygstart cygwin tail -f /foo/test.log | perl -pe 's/error/\e I know I can start a new instance using either of these: mintty -e ... cygstart tail ... But neither of those open in ANSI mode, so I can't do... (0 Replies)
Discussion started by: Validatorian
0 Replies

5. Shell Programming and Scripting

Cygwin and simple script with if

I am having an issue with using cygwin (on Windows XP). My script errors on if -command. The script here works fine on Linux, but cygwin fails... #!/bin/sh if then echo "Test" fi The error -message: ./ShellTest.sh: line 4: syntax error near unexpected token `fi' ./ShellTest.sh:... (1 Reply)
Discussion started by: jussist
1 Replies

6. Shell Programming and Scripting

Cygwin-shell script

hi, I am using Cygwin for running the shell script. If i execute the following command at the prompt output is obtained. grep echo * The same i have put in a file and when am trying to execute it is throwing error. IP.sh echo "Starting command..........." grep echo * ... (9 Replies)
Discussion started by: flamingo_l
9 Replies

7. Shell Programming and Scripting

cygwin script problem windows

I'm using cygwin to make some scripts,but I have the following problem. If I create a simple script like this one: if echo "Error" exit 1 fi echo "`expr $1 + $2`" I obtain line 6: syntax error:unexpected end of file. If I create the same script with cat>filename.txt and execute it... (4 Replies)
Discussion started by: Max89
4 Replies

8. UNIX for Dummies Questions & Answers

cygwin scp script error

I'm using cygwin scp to copy a file down from a AIX server to my laptop. I've got he script working from the command line. The file I'm copying is Processed.Apr21 and I'm copying it to /event_transfer folder on my laptop. scp username@149.131.224.104:/var/Tivoli/logs/Events/processed.Apr21... (3 Replies)
Discussion started by: cav.turbo
3 Replies

9. Shell Programming and Scripting

how to run cgi -script on Cygwin ?

All, I would like to run a cgi script in cygwin which i have installed in WinXP. My CYGWIN directory structure is /var/www/ drwxrwx---+ 2 user Users 0 Nov 23 16:24 cgi-bin drwxrwx---+ 3 user Users 0 Oct 22 17:21 htdocs drwxrwx---+ 3 user Users 0 Oct 22 17:22 icons and another... (1 Reply)
Discussion started by: jambesh
1 Replies
Login or Register to Ask a Question
cgi_init(3)							     cgi/cgi.h							       cgi_init(3)

NAME
cgi_init - Initialize ClearSilver CGI environment SYNOPSIS
#include <cgi/cgi.h> NEOERR *cgi_init (CGI **cgi, HDF *hdf); ARGUMENTS
cgi - a pointer to a CGI pointer hdf_file - the path to an HDF data set file that will also be loaded into the dataset. This will likely have to a be a full path, as the HDF search paths are not yet set up. Certain things, like DESCRIPTION
cgi_init initializes the ClearSilver CGI environment, including creating the HDF data set. It will then import the standard CGI environ- ment variables into that dataset, will parse the QUERY_STRING into the data set, and parse the HTTP_COOKIE into the data set. Note that if the var xdisplay is in the form data, cgi_init will attempt to validate the value and launch the configured debugger on the CGI program. These variables have to be specified in the hdf_file pointed to by hdf_file. The default settings do not allow debugger launching for security reasons. RETURN VALUE
cgi - an allocated CGI struct, including SEE ALSO
cgi_debug_init(3), cgi_parse(3), cgi_destroy(3), cgi_js_escape(3), cgi_html_escape_strfunc(3), cgi_register_strfuncs(3), cgi_output(3), parse_rfc2388(3), cgi_url_validate(3), open_upload(3), cgi_cs_init(3), cgi_url_escape_more(3), cgi_html_strip_strfunc(3), cgi_neo_error(3), cgi_redirect(3), cgi_filehandle(3), cgi_register_parse_cb(3), cgi_url_escape(3), cgi_init(3), cgi_redirect_uri(3), cgi_cookie_clear(3), cgi_url_unescape(3), cgi_vredirect(3), cgi_display(3), cgi_html_ws_strip(3), cgi_error(3), cgi_cookie_set(3), cgi_text_html_strfunc(3), cgi_cookie_authority ClearSilver 12 July 2007 cgi_init(3)