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
# 1  
Old 09-09-2010
Script for cygwin, HDF-EOS for converting HDF to TIF

I found a script from HDF-EOS for converting HDF to TIF, i did all steps but when i run there is some errors.
Link of instructions: http://newsroom.gsfc.nasa.gov/sdptoo...h_job_Help.txt

What I do rong about script?
Code:
#! /bin/sh
	# 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"
	for i in  `find .` ; do

	hdffile=`file $i | awk '{print 1.58€}'`

	if [ "$hdffile" = "Hierarchical" ] ; then

	sed 's/input/'$i'/' heg_template_unix.prm > $i.prm
	/home/username/heg2.9/HEG/bin/resample -p $i.prm
	fi
	done


Last edited by pludi; 09-09-2010 at 07:45 AM..
# 2  
Old 09-10-2010
something wrong in here?

Code:
	hdffile=`file $i | awk '{print 1.58€}'`

and paste the error log.
This User Gave Thanks to rdcwayx For This Post:
# 3  
Old 09-10-2010
The stupid plugin of Chrome, changes the $ to euro.....
This is the correct code........... but it steel not working Smilie any ideas or can someone to explain to me what does.

Code:
#! /bin/sh
	# 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"
	for i in  `find .` ; do

	hdffile=`file $i | awk '{print $2}'`

	if [ "$hdffile" = "Hierarchical" ] ; then

	sed 's/input/'$i'/' heg_template_unix.prm > $i.prm
	/home/user/heg2.9/HEG/bin/resample -p $i.prm
	fi
	done

# 4  
Old 09-11-2010
can you run the script by:

Code:
/bin/sh -x your_script

and paste the output.
# 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.
# 6  
Old 09-12-2010
Quote:
Originally Posted by rdcwayx
can you run the script by:

Code:
/bin/sh -x your_script

and paste the output.
Code:
My_name@My-desktop:~/Desktop/Script_for_MODIS$ /bin/sh -x myScript.sh 
+ find .
+ file .
+ awk {print $2}
+ hdffile=d1.57€irectory
+ [ directory = Hierarchical ]
+ file ./heg_template_unix_swath.prm
+ awk {print }
+ hdffile=ASCII
+ [ ASCII = Hierarchical ]
+ file ./myScript.sh
+ awk {print $2}
+ hdffile=POSIX
+ [ POSIX = Hierarchical ]

# 7  
Old 09-14-2010
I did some Changes and i ran again the script:
Code:
/bin/sh -x your_script

Code:
+ find .
+ file .
+ awk {print $2}
+ hdffile=directory
+ [ directory = Hierarchical ]
+ file ./MOD04_L2.A2005001.0745.051.2010183180242_mod04.tif
+ awk {print $2}
+ hdffile=TIFF
+ [ TIFF = Hierarchical ]
+ file ./MOD04_L2.A2005001.0745.051.2010183180242_mod04.tif.met
+ awk {print $2}
+ hdffile=ASCII
+ [ ASCII = Hierarchical ]
+ file ./MOD04_L2.A2005001.0745.051.2010183180242_mod04.tif.ovr
+ awk {print $2}
+ hdffile=TIFF
+ [ TIFF = Hierarchical ]
+ file ./myScript.sh
+ awk {print $2}
+ hdffile=POSIX
+ [ POSIX = Hierarchical ]
+ file ./heg_template_unix.prm
+ awk {print $2}
+ hdffile=ASCII
+ [ ASCII = Hierarchical ]
+ file ./MOD04_L2.A2005001.0745.051.2010183180242_mod04.tif.aux.xml
+ awk {print $2}
+ hdffile=ASCII
+ [ ASCII = Hierarchical ]


Last edited by vardaloupas; 09-14-2010 at 01:08 PM..
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