• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help with Unix Scripts  RSS feed

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to create a script in UNIX that takes 'images.tar.gz' and unzips. Could anyone give me some examples or know how I might do so. Also, I have created a java program that gets data by FTP and how do I call this java program in order to execute in my Unix scripts. Anyways, how are you doing, tell me what you have been up to.
 
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can unzip and explode all the files with a single command line:

A script seems like overkill, but if you tell me which shell you like to use I'll write an example for you.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
bob morkos
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bourne Shell (The easiest one from what I here)
Thanks in advance. Another question, how do you execute a script (downloader.sh) in a Unix command.
> do you just type in the unix command line
Unix command line> downloader.sh

Originally posted by Michael Ernest:
[B]You can unzip and explode all the files with a single command line:

A script seems like overkill, but if you tell me which shell you like to use I'll write an example for you.
[/B]

 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write this in a file called downloader:

Make sure the '#!' are the very first two characters in the file.
Turn on the execute bit:

and now the script will run in the Bourne shell with normal command-line invocation:
You can dispense with the .sh suffix if you want; I usually do because it's not really that helpful once a script is self-executing.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
bob morkos
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't seem to be running my scripts at all. Could you tell me how I can run my test script. I would like to thank you in advance.

 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You sure you have that '#!/bin/sh' as the very first line in the script? If so, check to make sure that sh is indeed available from /bin. If not, change this line to #!/usr/bin/sh.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
bob morkos
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it to work now. I had to type:
$sh testing.sh
How do you execute a script file within a java program. I think I have to use java.lang.runtime. I have started doing something like this and it does not work.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!