Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

problem with execution of script  RSS feed

Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a sed command in unix(solaris)to append a word to say second line of the script..
contents of the script called has just 2 lines.

When I execute it in command line, it appends the line after 3rd line.

But when I execute the script like this-> "" , nothing happens.

But when is run the script as "ksh", the desired result is produced.

How does it make a difference?
I did a echo $SHELL to find that my current shell is /bin/ksh
"whence ksh" gives me /bin/usr/ksh

running the script by mentioning the shell explicitly gives me right results(/bin/ksh or /bin/usr/ksh both gives right results )
but just doesn't work. I assume it must use the default shell-/bin/ksh

What is happening here?
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To be run without an explicit 'ksh' the script needs to have the 'executable' bit set and the OS needs to know which program to use to interpret your script. If prefixed by #! (hash bang), the OS will treat the first line of your script as defining the name of the program to run to interpret the rest of the script. See .

If you are expecting it to use ksh then I would expect the script file to contain

To set the executable bit

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!