LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-10-2005, 01:08 AM   #1
neerajchaudhari
Member
 
Registered: Jun 2005
Location: Pune
Distribution: mandrake
Posts: 30

Rep: Reputation: 15
linux command for the task


hello everyone,

i am a newbie to linux, recently i am exploring the various commands of linux with thier options and a few thigs about shell scripts, i have encountered a problem

i have a variable defined in my shell script file (try.sh) as java=/usr/j2sdk1.4.2_09
now i want to set this path to the JAVA_HOME in jboss-3.2.6, which resides in the /usr directory, .i.e. the path is /usr/jboss-3.2.6/bin , the run.sh file in bin contains JAVA_HOME
i want to append this at hte start of the run.sh file
and it should be done when i am executing the try.sh file

how shall i go about it
waiting eagerly for the reply
thanks in advance
 
Old 09-10-2005, 04:44 AM   #2
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Quote:
the run.sh file in bin contains JAVA_HOME
i want to append this at hte start of the run.sh file
and it should be done when i am executing the try.sh file
Uhh, if I'm reading this right, the variable JAVA_HOME is already defined in run.sh but you you want to place this in the beginning of run.sh script? If so, just move the variable to the beginning of the script.

I don't really understand what you're asking....sorry.

-twantrd
 
Old 09-10-2005, 09:20 AM   #3
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
Nor do I.

Perhaps excerpts of the relevant scripts would help (in "Code" blocks, please). Also more formal capitalization might make your post easier to read, therefore easier to understand, therefore easier to answer. Also, please use "Spell Check", "Preview Reply", & "Edit" -- 'hte' is a ...

Are you trying to use one script to rewrite another?
 
Old 09-10-2005, 09:27 AM   #4
neerajchaudhari
Member
 
Registered: Jun 2005
Location: Pune
Distribution: mandrake
Posts: 30

Original Poster
Rep: Reputation: 15
i will explain
my scriptfile try.sh contains the code which checks for j2sdk installation in a machine, if no installation exists then
the script installs the j2sdk, and then i manually set the JAVA_HOME in the run.sh file in jboss/bin
if the installation exists, then i store the path of j2sdk in a variable
now i want to assign the path stored in the variable to JAVA_HOME in the run.sh file in jboss/bin

how shall i do it
 
Old 09-10-2005, 09:57 AM   #5
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
1) It is unnecessary to e-mail us your posts -- we get notifications of new posts from LQ. Please don't do that, it clutters my InBox.

2) Please! This is a forum not a !@#$%^&* chatroom. Be so kind & respectful of our eyesight & time as to use relatively formal written English -- capitalization, punctuation, & spelling. In US & UK English the 1st person personal pronoun is 'I' not 'i'. I may be an old stick-in-the-mud, but I find 'i' offensive, & if you can't stop doing that, I will simply unsubscribe from this thread.

Double spacing between paragraphs improves readability.

Do you let the text box wrap your lines? -- Your posts look choppy, as if you are adding newlines to fit your display.

3) I still am not sure what you want to do, why don't you try responding to the Q's in my previous post?
 
Old 09-10-2005, 02:59 PM   #6
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Quote:
i will explain
my scriptfile try.sh contains the code which checks for j2sdk installation in a machine, if no installation exists then
the script installs the j2sdk, and then i manually set the JAVA_HOME in the run.sh file in jboss/bin
if the installation exists, then i store the path of j2sdk in a variable
now i want to assign the path stored in the variable to JAVA_HOME in the run.sh file in jboss/bin

how shall i do it
Hmm, ok. A copy/paste of your script would be helpful and an explanation of what part in the script that is not working would be great. In your 'try.sh' script, you want to set JAVA_HOME if there is no j2sdk installation right? Would something simple like this work for you?

[try.sh script]
#!/bin/sh

#There is no j2sdk installation
.... #installs j2sdk under /usr/local/j2sdk1.4

echo "JAVA_HOME=/usr/local/j2sdk1.4" > run.sh


Again, a snippet of your code would be helpful so we can fix that.

-twantrd
 
Old 09-11-2005, 03:43 AM   #7
neerajchaudhari
Member
 
Registered: Jun 2005
Location: Pune
Distribution: mandrake
Posts: 30

Original Poster
Rep: Reputation: 15
The try.sh contains:-
# ! /bin/sh
..............
...........
.............
j=`sed 's%\(.*\)lib/tools.jar%\1%' abc`

where abc is a file which contains the path of j2sdk installation,
after the execution of the above mentioned command variable j will contain the path of j2sdk installation till the j2sdk directory
lets say /usr/local/neeraj/j2sdk1.4.2_09
as per your suggestion, if i execute the command
echo "JAVA_HOME=$j" >> /usr/jboss/bin/run.sh
the JAVA_HOME gets appended at the end of the file run.sh
i want it to paste it at the top of the file
 
Old 09-11-2005, 06:23 AM   #8
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Quote:
echo "JAVA_HOME=$j" >> /usr/jboss/bin/run.sh
the JAVA_HOME gets appended at the end of the file run.sh
i want it to paste it at the top of the file
Why not just save the contents of run.sh into a different file and then append it afterwards? Like so:

1. copy run.sh to run.sh.body
2. echo "JAVA_HOME=$j" > /usr/jboss/bin/run.sh
3. echo "" >> /usr/jboss/bin/run.sh; cat run.sh.body >> /usr/jboss/bin/run.sh

-twantrd
 
Old 09-12-2005, 01:08 AM   #9
neerajchaudhari
Member
 
Registered: Jun 2005
Location: Pune
Distribution: mandrake
Posts: 30

Original Poster
Rep: Reputation: 15
thanks a lot sir, it worked

i have another query ( hope you don't get tired of it !!!!)
how to make an autorun cd in linux
i.e. i will write a cd, the contents of the cd would be say, a bin file of j2sdk and the script try.sh, now what i
want to do is, the moment i insert the cd in the cdrom, the cdrom should get mounted automatically, and the try.sh
script should start executing


once again thanks a lot sir
bye
 
Old 09-12-2005, 02:01 AM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
That's not going to happen. Some distros support the
supermount feature or other means of automatically
mounting the CD-ROM. Automatic execution of any-
thing will require a specific handler that integrates with
the mount. But for securities sake I pray no-one will
ever write anything THAT stupid.


Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Task Management for linux ravalox Linux - Software 4 09-24-2004 09:19 AM
Linux Task Manager Shotz Linux - Newbie 6 02-25-2004 03:37 PM
task switching in linux rainmann Linux - General 6 01-20-2004 09:29 PM
Scheduled task in linux? Dakkar Linux - Newbie 4 12-30-2003 09:54 AM
Task Manager in Linux? FutureEX Linux - General 2 10-18-2003 04:11 PM


All times are GMT -5. The time now is 10:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration