Originally posted by Xplorer4x4
View Post
Announcement
Collapse
No announcement yet.
Using elif or else if?
Collapse
This topic is closed.
X
X
-
Originally posted by Xplorer4x4 View PostCode:#Exec=searchforarchives.sh %U
As for the success dialog I am not sure it will work with this script as is, find returns true if any files where found or not so will always give you the success popup. The only way I can think of solving this is to store the output from find in a variable and passing this variable to ark later on after you check its contents.
Bash Script:
Code:#!/bin/bash searchextractrar() { input="${1}" files=$(find -iregex '.*[^p][^a][^r][^t]..\.rar\|.*part0[^023456789]\.rar\|.*/.?.?.?.?.?.?\.rar') if [[ -z "${files}" ]]; then ark --batch --autodestination ${files}; else kdialog --passivepopup "No archives found in ${input}." 60 return 1 #Change to exit 1 to stop the script on first failure fi } ...
Code:% cat test#!/bin/bash echo $@ echo "Testing \$@" for a in $@; do echo $a done echo "Testing \$*" for a in $*; do echo $a done echo "Testing \"\$@\"" for a in "$@"; do echo $a done echo "Testing \"\$*\"" for a in "$*"; do echo $a done echo "Testing for a" for a; do echo $a done echo "Testing shift" while [[ -n "$1" ]]; do echo $1 shift done
Note that "4 5" is a single argument as is " " and 6\ 7 but 1 and 2 are separate arguments. This is so you can see how bash treats each of the arguments.
Code:% bash test 1 2 "4 5" " " 6\ 7 1 2 4 5 6 7 Testing $@ 1 2 4 5 6 7 Testing $* 1 2 4 5 6 7 Testing "$@" 1 2 4 5 6 7 Testing "$*" 1 2 4 5 6 7 Testing for a 1 2 4 5 6 7 Testing shift 1 2 4 5 6 7
You should be able to use any of the variants that produce the right output (I would go for "for a; do...").
Lastly this part of the ark man page might be of interest:
-o, --destination directory
Default the extraction directory to directory. If not passed, the current path is used.
...
-e, --autodestination
The destination argument will be set to the path of the first file supplied.
Default the extraction directory to directory. If not passed, the current path is used.Last edited by james147; Nov 10, 2012, 07:05 PM.
- Top
- Bottom
Comment
-
Originally posted by james147 View PostThis line is commented out try deleting the #
As for the success dialog I am not sure it will work with this script as is, find returns true if any files where found or not so will always give you the success popup. The only way I can think of solving this is to store the output from find in a variable and passing this variable to ark later on after you check its contents.
Bash Script:
Code:#!/bin/bash searchextractrar() { input="${1}" files=${find -iregex '.*[^p][^a][^r][^t]..\.rar\|.*part0[^023456789]\.rar\|.*/.?.?.?.?.?.?\.rar'} if [[ -z "${files}" ]]; then ark --batch --autodestination ${files}; else kdialog --passivepopup "No archives found in ${input}." 60 return 1 #Change to exit 1 to stop the script on first failure fi } ...
First the comment, that was likely a typo. I have 2 exec lines so I can go back and forth from konsole output to background processing quickly.
Secondly, the new script.
Code:/usr/local/bin/searchforarchives.sh: line 6: ${find -iregex '.*[^p][^a][^r][^t]..\.rar\|.*part0[^023456789]\.rar\|.*/.?.?.?.?.?.?\.rar'}: bad substitution
OS: Kubuntu 12.10/Windows 8
CPU: Intel Core i7 2600K
Motherboard: Gigabyte GA-Z77X-UD5H
Memory: 2x4GB Corsair Dominator
Graphics Card: MSI R7770
Monitor: Dell 2208WFP
Mouse: Mionix NAOS 5000
PSU: Corsair 520HX
Case: Thermaltake Mozart TX
Cooling: Thermalright TRUE Black Ultra-120 eXtreme CPU Heatsink Rev C
Hard Drives: 1x180 GB Intel 330 SSD - 1xWD 1 TB Caviar Black - 1xWD 2 TB Caviar Green - 2xWD 3 TB Caviar Green
- Top
- Bottom
Comment
-
Originally posted by Xplorer4x4 View PostCode:/usr/local/bin/searchforarchives.sh: line 6: ${find -iregex '.*[^p][^a][^r][^t]..\.rar\|.*part0[^023456789]\.rar\|.*/.?.?.?.?.?.?\.rar'}: bad substitution
The rest of the post is my saying, and explaing why you should use
Code:for file; do searchextractrar ${file} done
Code:for file in "${@}" ; do searchextractrar ${file} done
Code:for file in ${@} ; do searchextractrar ${file} done
Last edited by james147; Nov 10, 2012, 06:48 PM.
- Top
- Bottom
Comment
-
Originally posted by james147 View PostOpps, my bad, it should be $(find ... ) not ${find ...}
FAILURE (KCmdLineArgs): Argument out of bounds
Application requests for arg(0) without checking count() first.
The rest of the post is my saying, and explaing why you should use
Code:for file; do searchextractrar ${file} done
Code:for file in "${@}" ; do searchextractrar ${file} done
Code:for file in ${@} ; do searchextractrar ${file} done
OS: Kubuntu 12.10/Windows 8
CPU: Intel Core i7 2600K
Motherboard: Gigabyte GA-Z77X-UD5H
Memory: 2x4GB Corsair Dominator
Graphics Card: MSI R7770
Monitor: Dell 2208WFP
Mouse: Mionix NAOS 5000
PSU: Corsair 520HX
Case: Thermaltake Mozart TX
Cooling: Thermalright TRUE Black Ultra-120 eXtreme CPU Heatsink Rev C
Hard Drives: 1x180 GB Intel 330 SSD - 1xWD 1 TB Caviar Black - 1xWD 2 TB Caviar Green - 2xWD 3 TB Caviar Green
- Top
- Bottom
Comment
-
Code:kdialog --passivepopup "No archives found in ${input}." 60 return 1 #Change to exit 1 to stop the script on first failure
Code:kdialog --passivepopup "No archives found in ${input}." 60 return 1 #Change to exit 1 to stop the script on first failure
- Top
- Bottom
Comment
-
I actually tried that already. Didnt know if it woudl matter or not but when I tried ti, same error as my last post.OS: Kubuntu 12.10/Windows 8
CPU: Intel Core i7 2600K
Motherboard: Gigabyte GA-Z77X-UD5H
Memory: 2x4GB Corsair Dominator
Graphics Card: MSI R7770
Monitor: Dell 2208WFP
Mouse: Mionix NAOS 5000
PSU: Corsair 520HX
Case: Thermaltake Mozart TX
Cooling: Thermalright TRUE Black Ultra-120 eXtreme CPU Heatsink Rev C
Hard Drives: 1x180 GB Intel 330 SSD - 1xWD 1 TB Caviar Black - 1xWD 2 TB Caviar Green - 2xWD 3 TB Caviar Green
- Top
- Bottom
Comment
-
Code:#!/bin/bash searchextractrar() { input="${1}" files=$(find -iregex '.*[^p][^a][^r][^t]..\.rar\|.*part0[^023456789]\.rar\|.*/.?.?.?.?.?.?\.rar') if [[ -z "${files}" ]]; then ark --batch --autodestination ${files}; else kdialog --passivepopup "No archives found in ${input}." 60 return 1 #Change to exit 1 to stop the script on first failure fi } for file in "${@}" ; do searchextractrar ${file} done
OS: Kubuntu 12.10/Windows 8
CPU: Intel Core i7 2600K
Motherboard: Gigabyte GA-Z77X-UD5H
Memory: 2x4GB Corsair Dominator
Graphics Card: MSI R7770
Monitor: Dell 2208WFP
Mouse: Mionix NAOS 5000
PSU: Corsair 520HX
Case: Thermaltake Mozart TX
Cooling: Thermalright TRUE Black Ultra-120 eXtreme CPU Heatsink Rev C
Hard Drives: 1x180 GB Intel 330 SSD - 1xWD 1 TB Caviar Black - 1xWD 2 TB Caviar Green - 2xWD 3 TB Caviar Green
- Top
- Bottom
Comment
-
Try commenting out the ark line (and add a "echo" after it) see if you get the same error, if you do then try it for the kdialog line. ie
Code:#ark --batch --autodestination ${files}; echo # Just to stop the syntax error caused by an empty if
- Top
- Bottom
Comment
-
That's what I was thinking(but my brains on stupid mode today lol), so I couldn't think how to do it. No error output that time, so does this mean ark can't be passed a variable in this form?OS: Kubuntu 12.10/Windows 8
CPU: Intel Core i7 2600K
Motherboard: Gigabyte GA-Z77X-UD5H
Memory: 2x4GB Corsair Dominator
Graphics Card: MSI R7770
Monitor: Dell 2208WFP
Mouse: Mionix NAOS 5000
PSU: Corsair 520HX
Case: Thermaltake Mozart TX
Cooling: Thermalright TRUE Black Ultra-120 eXtreme CPU Heatsink Rev C
Hard Drives: 1x180 GB Intel 330 SSD - 1xWD 1 TB Caviar Black - 1xWD 2 TB Caviar Green - 2xWD 3 TB Caviar Green
- Top
- Bottom
Comment
-
Been awhile since I got any help on this. Any one willing to lend a hand?OS: Kubuntu 12.10/Windows 8
CPU: Intel Core i7 2600K
Motherboard: Gigabyte GA-Z77X-UD5H
Memory: 2x4GB Corsair Dominator
Graphics Card: MSI R7770
Monitor: Dell 2208WFP
Mouse: Mionix NAOS 5000
PSU: Corsair 520HX
Case: Thermaltake Mozart TX
Cooling: Thermalright TRUE Black Ultra-120 eXtreme CPU Heatsink Rev C
Hard Drives: 1x180 GB Intel 330 SSD - 1xWD 1 TB Caviar Black - 1xWD 2 TB Caviar Green - 2xWD 3 TB Caviar Green
- Top
- Bottom
Comment
-
Windows no longer obstructs my view.
Using Kubuntu Linux since March 23, 2007.
"It is a capital mistake to theorize before one has data." - Sherlock Holmes
- Top
- Bottom
Comment
-
Originally posted by Snowhog View PostOS: Kubuntu 12.10/Windows 8
CPU: Intel Core i7 2600K
Motherboard: Gigabyte GA-Z77X-UD5H
Memory: 2x4GB Corsair Dominator
Graphics Card: MSI R7770
Monitor: Dell 2208WFP
Mouse: Mionix NAOS 5000
PSU: Corsair 520HX
Case: Thermaltake Mozart TX
Cooling: Thermalright TRUE Black Ultra-120 eXtreme CPU Heatsink Rev C
Hard Drives: 1x180 GB Intel 330 SSD - 1xWD 1 TB Caviar Black - 1xWD 2 TB Caviar Green - 2xWD 3 TB Caviar Green
- Top
- Bottom
Comment
-
Originally posted by Xplorer4x4 View PostWe are long past that at this point. Check back a page or two.
- Top
- Bottom
Comment
Comment