2014-02-11 3 views
-1

내 용어가 올바르지 않으면 도움을 청합니다. - 내 파일 filename.sh을 연결Windows에서 bash 쉘 스크립트를 실행하는 일정 (question2)

내가 .sh로 파일을 실행하려고, 나는 기본적으로
1 위의 질문에 대한 답을 사용하여이 작업을 수행 :이 질문 here에서에 구축

filename.bat filename.bat
은 다음과 같다 : 이것은 일반적으로 내 대부분의 작동

@echo off 

c: 
chdir c:\cygwin\bin 

bash --login %* 

* .sh 파일의 예는 다음과 같습니다.

#!/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' '{}' ';' 

위의 내용은 두 번 클릭하면 작동합니다.
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 

그러나 1 & 위의 명령은 cygwin에서 명령을 실행하면 작동합니다. ./filename.sh

나는 위의 1과 2가 두 번 클릭하여 작동하지 않는 이유는 위의 명령을 사용하여 작동 할 때 ./filename.sh?

참고 : 나는 윈도우 XP에서 Cygwin에서 실행하고

편집 : 이것은 내가이 cmd를 창이 열립니다 및 디스플레이 그것을 점에서을 더블 클릭하여 작동하지 않습니다 말할 때 내가 무엇을 얻을 수 있습니다.

This is what I get when I say it does not work by double clicking it FormatCSVFiles.sh는 내가 더블 클릭하는 파일입니다.

+2

"작동하지 않음"이란 무엇을 의미합니까? 오류 메시지가 있습니까? – tripleee

+0

@ tripleee 좋은 지적, 나는 내 질문을 업데이 트했습니다, 다른게 있다면 알려 주시기 바랍니다. – HattrickNZ

답변

0

수정 : 실제로 작동합니다. echo 명령어를주기 전에 디렉토리를 변경하지 않았습니다. 그래서 내 바보 같은 실수. tks.

관련 문제