Fun with StackOverflow questions: finding answers while having no prior domain knowledge of the topics, with a little bit of detective work.
These are the questions I had the most fun answering on SO – hopefully I will find time to write a few words for each of them.
I had no idea what JSCH was. A quick Google search returns: “JSch is a pure Java implementation of SSH2”.
The question details a seemingly bizarre behavior, but I’ve used chmod before: maybe I can figure it out.
OP describes “775” as an integer. That clicked something. I recall that permission codes were not interpreted as decimal; but rather either hexadecimal or octal.
Converting 775 from decimal to hex yields 0x307. Close! But he’s getting 0x407 instead.
Let’s try octal: this time we get 0o1407. That’s not it either.
Hmm, 775, 407, 0x307, 0o1407. Eureka! It’s quite possible that JSch or Filezilla truncates any overflow for permission codes with value greater than 0o777, because there are only 3 permission groups: user, group, world (as it’s not unreasonable to assume there’s nothing past the 3rd least significant bit). So decimal 775 -> octal 0o1407 must have been truncated to octal 0o407.
I submitted the answer with an explanation of permission groups, and the decimal representation of 0o775, which is 509.
Answer accepted by OP =)
I had never seen Perl code until then, but then I thought, why not!
I read the question, scanned through some quick-start tutorials on Perl, grabbed what I remembered on regex, and answered with a working solution. All done, in less than 4 minutes.
I actually didn’t even realize this was doable in shell script, a few minutes of research taught me otherwise!
A question that more or less answered itself when I reviewed the documentation for stringstream.
The requirements changed from “minus X days” to “minus X working days” after I answered the question, but I didn’t give up. Perseverance paid off!