derda Posted July 18, 2011 Share Posted July 18, 2011 on linux a bash script can be executed by a simply click. on osx $pwd seems messed ie files not found in: cp filea ../blbl/blbl/ when not executed alike ./script but with a click as *.command or *.sh someone could fix my work below? i calculated 2 min and already spent moren than an hour on such ...:-( Thanks ---------- tell application "Finder" to set f to POSIX path of ((container of (path to me)) as alias) tell application "Terminal" activate set t to (make new terminal) tell t tell (make new session at the end of sessions) do shell script "echo echo Copying files echo sleep 5 cp -r -v &f&/a.txt &f&/../bl/blala/a.txt exit 0" end tell end tell end tell Link to comment https://www.insanelymac.com/forum/topic/262654-click-execute-file-copy-pls-debug-my-file/ Share on other sites More sharing options...
derda Posted July 19, 2011 Author Share Posted July 19, 2011 Thanks, but i get an error with that. "line 6 could not cd" or alike. Yes simplest to only use bash? I only need to copy alike: cp -r -v bla.txt ../Long\ Winglets/xx/plugins/b1/ any idea on how to handle $pwd difference on osx? (with a mouseclick on *.command) Regards Michael Link to comment https://www.insanelymac.com/forum/topic/262654-click-execute-file-copy-pls-debug-my-file/#findComment-1716879 Share on other sites More sharing options...
derda Posted July 20, 2011 Author Share Posted July 20, 2011 many thanks. Regards #!/bin/bash echo "" echo "Copying files" sleep 1 # 2. for each file in the current directory listing for file in `ls` do # 3. Skip it if it's a directory... if [ -d $file ] then echo $file " is a directory." else if [ "$file" = "cfile.txt" ]; then cp $file ../bl\ blbla/ccc/aaaeb/asbg cp $file ../ee/dsdfadf/asdfasdfa echo "Copying " $file sleep 1 fi if [ "$file" = "file3.ini" ]; then cp $file ../dfaf\ bdds/S6sfsdfas/sdfsf/fsfsdf echo "Copying " $file sleep 1 fi fi done Link to comment https://www.insanelymac.com/forum/topic/262654-click-execute-file-copy-pls-debug-my-file/#findComment-1717435 Share on other sites More sharing options...
derda Posted July 21, 2011 Author Share Posted July 21, 2011 it seems that I need to cut off with a regex all after the last / from $0 as the path is alike: /somehwere/General Stuff/blalb/blal/ Don't have time now for Mac, maybe next week. Link to comment https://www.insanelymac.com/forum/topic/262654-click-execute-file-copy-pls-debug-my-file/#findComment-1718318 Share on other sites More sharing options...
derda Posted July 23, 2011 Author Share Posted July 23, 2011 Thanks but I got an error with your script. Anyway this below works and is more simple: wherami=$(dirname "${0}") cp "${wherami}/${nameOfTheFileToCopy}" "${wherami}/"../blal/bllb/ Link to comment https://www.insanelymac.com/forum/topic/262654-click-execute-file-copy-pls-debug-my-file/#findComment-1720529 Share on other sites More sharing options...
Recommended Posts