aspose file tools*
The moose likes Linux / UNIX and the fly likes making an executable shell script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "making an executable shell script" Watch "making an executable shell script" New topic
Author

making an executable shell script

prateek urmaliya
Ranch Hand

Joined: Sep 15, 2006
Posts: 87
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 ?


this message brought to you by .... PIE! .... it's yummy! ;)
Anand Hariharan
Rancher

Joined: Aug 22, 2006
Posts: 257

Is . (CWD) in your PATH?

Try

echo $PATH
./your_script


"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery
prateek urmaliya
Ranch Hand

Joined: Sep 15, 2006
Posts: 87
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 ?
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

You never can append a script to the path - just directories.

And with

you start your script from the current directory.


http://home.arcor.de/hirnstrom/bewerbung
prateek urmaliya
Ranch Hand

Joined: Sep 15, 2006
Posts: 87
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 ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41906
    
  63
Just to be clear on this, you typed

./myscript.ksh

and it didn't run? What actually happened?


Ping & DNS - my free Android networking tools app
prateek urmaliya
Ranch Hand

Joined: Sep 15, 2006
Posts: 87
Hi Ulf,
I did a from my CWD that holds myscript.ksh
and got a
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
prateek urmaliya
Ranch Hand

Joined: Sep 15, 2006
Posts: 87
Hi Ben,

I tried what Ulf suggested but still I am getting

What could cause this ?
Anand Hariharan
Rancher

Joined: Aug 22, 2006
Posts: 257

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

    Joined: Sep 15, 2006
    Posts: 87
    Hi Anand,

    I have sent you a PM.
    Anand Hariharan
    Rancher

    Joined: Aug 22, 2006
    Posts: 257

    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

    Joined: Jun 02, 2003
    Posts: 1923

    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

    Joined: Sep 15, 2006
    Posts: 87
    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 ]
     
    wood burning stoves
     
    subject: making an executable shell script