How to call shell scripts from java properly

shell photo

Photo by dd21207

This has caused me some grief over the past few weeks, so here’s some tips on calling bash scripts from java correctly.

Use ProcessBuilder. Please.

Make sure you set the redirectErrorStream to true, or make other provisions for handling stderr.

I’ve found that inheritIO is useful. Not calling this caused a failure in a bash script that called other java programs.

Make sure your shell scripts have are executable, or that you call them with ‘bash scriptname’. Tarballs preserve permissions, zipfiles do not.

Read the output of the shell script, even if you do nothing with it (but you probably want to log it, if nothing else). If you don’t, buffers fill up and the process will hang:

final InputStreamReader isr = new InputStreamReader(p.getInputStream());
final BufferedReader br = new BufferedReader(isr);
String line = null;
StringBuffer sb = new StringBuffer();
while ((line = br.readLine()) != null) {
sb.append(line).append("\n");
}

Check your exit values, and wait for your shell script to finish: (If looking for speed, or more complex process flow, write it in java.)


int exitValue = p.waitFor();
if (exitValue != 0) {
// error log
}


How to engage with recruiters

recruiter photo

Photo by JimsFlicker

If you are a software engineer or developer right now, you are in demand.  There’s a dearth of software developers, and so you are probably getting calls from recruiters.  This is location dependent–my understanding is that the SF market is white hot, and the market for software developers in Yuma CO is softer.

When I first was approached by a recruiter, I was flattered.  Here was a stranger trying to find me a job.  Quickly I realized that recruiters were not working for me (they get paid to place a candidate, so they are working for the company) and that most recruiters didn’t have a technical background at all.  This made me feel less charitable toward recruiters, and I have found that common amongst developers, especially now that they have so many job options.

Older and wiser, now I have a more balanced approach.  Here’s my tips for dealing with tech recruiters:

  • Communicate what I want.  This means knowing what I want in a new job or contract, which can include availability (both hours and start date), minimum rate, location, work condition (remote), technology, sector.  Tell the recruiter all this up front.  I often state: “hey, at this point in time, I’m rather picky, and I don’t want to waste your time.  Here is what would interest me: …”.  This lets them self select out quickly, before the “get to know you” phone call.  I should probably put this on my Hire Me page, now that I think about it.  Just need to make sure I keep this up to date.
  • Realize I am in in their database forever.  I gave my resume to someone in 2004 who I lived with who worked at a recruiting firm.  I still get calls from that same firm.
  • Make sure I am treated like a professional, and don’t put up with non professional acts.  Do they respond when I ask them to, answer my questions, and treat me with respect.  I actually had to hang up on a recruiter recently who, after I had told her I was busy and couldn’t talk right then, in an email and earlier on the call, continued to ask “just a few questions” about my skill set.  It wasn’t fun, but she was not being respectful of my time.
  • The other side of the coin is that I need to treat them with equal respect. That means being honest with them about needs and skills and responding to emails in a timely, respectful fashion.  It also means if I hear of someone with a needed skillset, doing an intro (wearing my informal recruiter hat).
  • Make the exchange of information a two way street.  Whenever I get contacted by a recruiter, they always want “5-10 minutes to talk to see how I can help you in your career”.  When I get them on the phone, I make sure to ask them questions about the market, other skills they’ve seen in demand, what specific technologies they’ve seen needs for, what kind of companies are hiring.
  • Thank them for supporting various meetups, if they do.  The local Java Users’ Group has pizza and soda provided every month by a recruiting firm.  This actually makes me more likely to respond to recruiters from that firm, because, while it’s not caviar, it’s nice to have dinner paid for.
  • Realize the difference between being sought for who I am (that’s being headhunted, and is reserved for senior folks and niches) and being sought for my skills.  I’ve never been in the position of having a stranger seeking me for who I am (I imagine internet famous folks like Matt Raible probably have), but I have had former co-workers do so.  Incidentally, the former is by far a better way to join an organization.
  • I keep my linked in profile up to date.  This makes it very easy to send recruiters a resume, should they ask for one.
  • I realize the tables may turn.  Right now, and for the near future, development is in great demand.  But I’ve been through one ‘software recession’ and I expect there will be more.  Beyond the basic dignity I ascribe to every human being, recruiters can get me a job.  So, except in the cases where recruiters aren’t respectful, I treat them with respect.
  • I don’t take random recruiter calls or requests on LinkedIn.  LinkedIn emails are different–if a recruiter has paid for a premium account, it’s easy enough to respond with a quick ‘not interested’ if the position isn’t for me.  But if a recruiter is trying to connect on LinkedIn without having met me at all, they are not serious.  If a recruiter is serious about getting in touch with me, I can be found in about a thousand different ways online.  I think recruiters who send LinkedIn requests are lazy and not worth responding to.
  • As above, I respond to recruiter emails, even if is just ‘no thanks’.  Again, basic human dignity.
  • Finally, I’m trying to cultivate a few good recruiters.  Whether these are referrals from a friend, or recruiters that I’ve met at an event, there are a few that stand out.  One recruiter (Dave from Technical Integrity) actually introduced me to a few of his friends so I could ask some exploratory questions about a different sector.  You better believe that I’ll recommend him and think of him when I have friends who are looking for work.  That company focuses on startups and full time employees, so I haven’t had the experience of working for them, but when my needs change, I will certainly see if they are looking.  The idea is to have the relationship last longer than a single contract.

Reviewing my list, I boil it down to:

  • recruiters are human beings, treat them like it
  • they don’t work for you
  • set your expectations and boundaries
  • software development is hot now, but won’t be forever

Any tips you have on engaging with recruiters?



RSS Pick: Bill Gurley

Bill Gurley writes at Above The Crowd.  He doesn’t write often–7 posts in 2014–and often they are simply “Welcome XXX to the Benchmark Capital family”.  (He is a GP at Benchmark, a VC fund.)

But when he dives in and covers a topic, it’s very informative.  Some of the meaty topics he covers:

The rarity with which he posts make him a perfect addition to an RSS reader–you probably won’t visit his site regularly, but when he does post, you’ll want to know.

I don’t see any evidence of him writing on Medium, but he does tweet.  (Incidentally, his twitversation score is 52.)

Enjoy



© Moore Consulting, 2003-2017 +