Hey finally I got the solution the problem was in rails file in script director. Make sure this file starts with this line :- #!/usr/bin/env ruby and in my file in the starting there was just a blank space and then this line was present.
Remove that space and now everything is working fine :)