• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

making an executable shell script

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am trying to run my jar from Unix box ,
I have created an executable jar abc.jar
and using this script

then named it myscript.ksh

but when I try to run myscript.ksh
I am getting ksh: myscript.ksh: not found
I did a ls -l and all have execute permission.
Am I missing something ?
 
Rancher
Posts: 280
VI Editor C++ Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is . (CWD) in your PATH?

Try

echo $PATH
./your_script
 
prateek urmaliya
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No it's not and I can't append it to PATH
also I don't have permission to copy the script in the DIR's that are in PATH.
but I plan to execute this script from CWD ,Is there a way around this ?
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You never can append a script to the path - just directories.

And with

you start your script from the current directory.
 
prateek urmaliya
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is . (CWD) in your PATH?


No it's not and I can't append it to PATH


I tried doing a

but no luck ,I have execute permission on this file

but when I do a
It's running fine,
what can be causing this ?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to be clear on this, you typed

./myscript.ksh

and it didn't run? What actually happened?
 
prateek urmaliya
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ulf,
I did a from my CWD that holds myscript.ksh
and got a
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Go back and look at what Ulf asked you to try.

The ./ at the beginning is important.
It says run the myscript.ksh in this directory.

Unlike with Windows, Unix by default, doesn't automatically look in the current working directory for programs.
 
prateek urmaliya
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ben,

I tried what Ulf suggested but still I am getting

What could cause this ?
 
Anand Hariharan
Rancher
Posts: 280
VI Editor C++ Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by prateek urmaliya:
Hi Ben,

I tried what Ulf suggested but still I am getting

What could cause this ?



  • Open a new terminal.
  • Change directory to where your script is.
  • [list]Do a [/list]
  • Execute your script like you have been advised multiple times.
  • Now take a snapshot of your terminal, upload it, and send us a link to this snapshot.

  • - Anand

    [Edit: Added closing List terminator]
    [ April 25, 2007: Message edited by: Anand Hariharan ]
     
    prateek urmaliya
    Ranch Hand
    Posts: 87
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Anand,

    I have sent you a PM.
     
    Anand Hariharan
    Rancher
    Posts: 280
    VI Editor C++ Debian
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by prateek urmaliya:
    Hi Anand,

    I have sent you a PM.



    I'll be damned -- don't have a clue! Quite wierd, I'll admit. Is there any reason you don't want to post the link to the image in the forum?

    Any case, there are a couple of things I would suggest you do.

    Since it is a small script, post its contents, especially its shebang line. Also please post the output of the following:
    .

    Of course, make sure whatever you post is kosher (both for yourself/your employer as well as for this forum).

    Sorry couldn't be of more help,
    - Anand
     
    Stefan Wagner
    Ranch Hand
    Posts: 1923
    Scala Postgres Database Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Where is the script located?
    Sometimes, entire drives are mounted, but prohibited to execute commands there (typically: dos/windows partitions - vfat, ntfs).

    does

    work?
     
    prateek urmaliya
    Ranch Hand
    Posts: 87
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi All,

    well I commited gross mistake of editing the file in textpad and then uploading the file then I read #2,
    I used vi for creating new script and it run fine
    Thanks Ulf,Stefan,Ben and Anand (not in order of appearance)
    from now V is for vi,
    I am still wondering how worked ?
    I need to attend my UNIX 101 class again.
    Thanks Guys for your help.

    [ April 28, 2007: Message edited by: prateek urmaliya ]
    [ April 28, 2007: Message edited by: prateek urmaliya ]
     
    reply
      Bookmark Topic Watch Topic
    • New Topic