Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

batch files in unix

  Asked By: Holly    Date: Dec 24    Category: Java    Views: 2874
  

any one know how to make and execute a bathc file in unix ? like in case of
windows we just write the command and save the file with .bat extension and just
double click to execute it but i am new in unix so how i can do in unix?

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Cambria Lopez     Answered On: Dec 24

A simple script would look like:

#!/bin/sh

echo "Hello, world!"

Where the first line consists of "#!<path to the shell to use - usually
/bin/sh>" and then the rest of the file  consists of the commands to execute  -
basically anything that you can do from the command  line.

Once the file has been saved, execute 'chmod 755 <script_file>' and you will
be able to use your script just like any other program on the system.

 
Answer #2    Answered By: Topaz Ramirez     Answered On: Dec 24

Thanks but tell me is this a right to execute  a java or anyother command  in unix

#!/bin/sh

java Helloworld.java

and if i have saved it with test.bat file  then i'll execute it like this?

chmod 755 test.bat
but what is this 755?

 
Answer #3    Answered By: Angie Bennett     Answered On: Dec 24

to set the file  permission so it could be executed by you.
try to search bash programming in the google.

 
Answer #4    Answered By: Ray Lawrence     Answered On: Dec 24

you put your command  in a file  of any name and make it executable with the
chmod "+x" command.

for help on chmod enter the command
man chmod

 
Didn't find what you were looking for? Find more on batch files in unix Or get search suggestion and latest updates.




Tagged: