-1

Apreciate any help and excuse me if my terminology is incorrect.
building on from this question here:

i am trying to run a .sh file, and I do this by using the answer in the question above, which is basically
1 - associating my file filename.sh with the filename.bat
filename.bat looks like this:

@echo off

c:
chdir c:\cygwin\bin

bash --login %*

This generally works for most of my *.sh files with an example being this:

#!/bin/bash

# Configure bash so the script will exit if a command fails.
set -e 

#this is the DIR i want to copy to 
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#this is the DIR i want to copy from
DIR2=/cygdrive/v/where/file/is

#cd to the dir where I want to copy the files to:
cd "$DIR"

#cp files and subdirectories of interest
#include the subdirs 
cp -r "$DIR2"/* .

# This will unzip all .zip files in all subdirectories under this one.
# -o is required to overwrite everything that is in there
find -iname '*.zip' -execdir unzip -o {} \;

# this will delete row 1-6 and the last row of all the csv files 
find ./ -iname '*.csv' -exec sed -i '1,6d;$ d' '{}' ';'

So the above works when I double click on it.

Some instances I have noted that do not work when I double click on them, is when the script contains something like below:
1->

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/PointB
    echo $DIR > test.txt #the text.txt file will not be created


2->

#this renames files in a directory, see [here][2]
for fname in Combined*.csv ; do mv "$fname" "$(echo "$fname" | sed -r 's/[0-9]{14}//')" ; done

But 1 & 2 above will work if i run them from cygwin with the command ./filename.sh

What I am wondering is why is 1 and 2 above not work for me, by double clicking on them, when they do work by invoking the command ./filename.sh?

Note: I am running cygwin on windows XP

EDIT: This is what I get when I say it does not work by double clicking it in that the cmd window opens up and displays this.

This is what I get when I say it does not work by double clicking it FormatCSVFiles.sh is the file I am double clicking on.

2
  • 2
    What do you mean by "don't work"? Is there an error message? Commented Feb 11, 2014 at 4:45
  • @tripleee good point, I have updated my question, let me know if there is anything else. Commented Feb 11, 2014 at 21:05

1 Answer 1

0

Correction: this actually works. I was not changing directory before giving the echo command. So a silly mistake by me . tks.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.