LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 06-17-2014, 05:49 AM   #1
apss_evaluator
Member
 
Registered: Mar 2012
Posts: 115

Rep: Reputation: Disabled
bash start script


Hi Linux Guru's

I'm running a start script for jboss7 that also calls another script named as deploy.ctl.

well the function of deploy.ctl is only just deploying apps in the order basis that we specify and will sow the apps deploy on my screen(1st deploy app1, 2nd deploy app02)

I want deploy.ctl to run but the results should not show on my screen, is there a way I can do it since it is only called by the start script?.

I saw online there is a function called silencing but I'm not sure if it will solve my problem
 
Old 06-17-2014, 06:28 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,189

Rep: Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673
I do not really understand, but probably redirecting will solve your issue:
<your original command> >/dev/null
 
Old 06-17-2014, 06:49 AM   #3
apss_evaluator
Member
 
Registered: Mar 2012
Posts: 115

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
I do not really understand, but probably redirecting will solve your issue:
<your original command> >/dev/null
Thanks for checking Pan I know its confusing, to make this simple,

lets say I created a script that when I run it will print a "hello world" in my screen
but I want to also run that script without showing the hello world and without commenting out the echo "hello world" in the script
 
Old 06-17-2014, 06:51 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,189

Rep: Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673
so that is the way:
script.sh
this will print hello world
script.sh >/dev/null
will print nothing, but will be executed the same way as before
 
1 members found this post helpful.
Old 06-17-2014, 07:06 AM   #5
apss_evaluator
Member
 
Registered: Mar 2012
Posts: 115

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
so that is the way:
script.sh
this will print hello world
script.sh >/dev/null
will print nothing, but will be executed the same way as before
Thanks Pan64! I'll try it
 
Old 06-18-2014, 07:56 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 5,119
Blog Entries: 10

Rep: Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815
You might want to consider:
Code:
script.sh 2>&1 /dev/null
What the 2>&1 will do is redirect BOTH stdout as well as stderr to /dev/null which means to send it to a file handle, the /dev/null which has no size and does not save what it's given; just a shortcut to send information to "nowhere". Using solely ">" will send only stdout to /dev/null.
 
1 members found this post helpful.
Old 06-19-2014, 03:08 AM   #7
apss_evaluator
Member
 
Registered: Mar 2012
Posts: 115

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rtmistler View Post
You might want to consider:
Code:
script.sh 2>&1 /dev/null
What the 2>&1 will do is redirect BOTH stdout as well as stderr to /dev/null which means to send it to a file handle, the /dev/null which has no size and does not save what it's given; just a shortcut to send information to "nowhere". Using solely ">" will send only stdout to /dev/null.
Many thanks Pan64 and rtmistler

I have included pgbouncer on my script and it looks good now :-) but there are still ignorable errors appear on my screen when pgbouncer boots up.

I want those errors to dissapear because I have assigned expected echoed messages through it.

how can I remove those ignorable errors and redirect to my logging instead?

this are the errors I want to remove on the screen and redirect to my logging:

2014-06-19 01:01:47.220 1544 LOG File descriptor limit: 32768 (H:32768), max_client_conn: 2000, max fds possible: 2215
2014-06-19 01:01:47.220 1544 LOG Stale pidfile, removing
ls: cannot access /opt/msp/pkg/jboss-vmss/bin/../standalone/deployments/coral_core.ear.*: No such file or directory
 
Old 06-19-2014, 03:15 AM   #8
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,189

Rep: Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673
the correct syntax is:
script.sh >/dev/null 2>&1
 
Old 06-19-2014, 03:47 AM   #9
apss_evaluator
Member
 
Registered: Mar 2012
Posts: 115

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
the correct syntax is:
script.sh >/dev/null 2>&1
Hi pan64

before I try it, will that include in my logging, I have also included inside my script this:

log_file='/tmp/restart.log'

I want to appear in restart.log the ignorable errors that pgbouncer instead of sending it on my screen while running the script

Last edited by apss_evaluator; 06-19-2014 at 03:52 AM.
 
Old 06-19-2014, 03:56 AM   #10
apss_evaluator
Member
 
Registered: Mar 2012
Posts: 115

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by apss_evaluator View Post
Hi pan64

before I try it, will that include in my logging, I have also included inside my script this:

log_file='/tmp/restart.log'

I want to appear in restart.log the ignorable errors that pgbouncer instead of sending it on my screen while running the script
also from my script I patterned the pgbouncer start

cd $PGBOUNCER_HOME && bin/pgbouncer -d $PGBOUNCER_HOME/cfg/pgbouncer.ini >> $log_file
 
Old 06-19-2014, 05:42 AM   #11
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,189

Rep: Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673
in that case you need to redirect the output to that file:
script.sh >/tmp/restart.log 2>&1
 
1 members found this post helpful.
Old 06-19-2014, 06:02 AM   #12
apss_evaluator
Member
 
Registered: Mar 2012
Posts: 115

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
in that case you need to redirect the output to that file:
script.sh >/tmp/restart.log 2>&1
Thanks again pan64, it worked!
 
Old 06-19-2014, 06:46 AM   #13
apss_evaluator
Member
 
Registered: Mar 2012
Posts: 115

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by apss_evaluator View Post
Thanks again pan64, it worked!
one more thing I noticed in my logs shows this:

Stopping jboss-as: .ESC[60G[ESC[0;32m OK ESC[0;39m]
Starting jboss-as: .......ESC[60G[ESC[0;32m OK ESC[0;39m]

it should look like this:
Stopping jboss-as: .[ OK ]
Starting jboss-as: .......[ OK ]

I remember when I constructed the script I put some font colors, but I already removed it
I also made a couple of check on my script and verified that all markers for the font colors are removed
whould you know what caused it?

Last edited by apss_evaluator; 06-19-2014 at 06:50 AM.
 
Old 06-19-2014, 07:34 AM   #14
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 5,119
Blog Entries: 10

Rep: Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815
Quote:
Originally Posted by apss_evaluator View Post
one more thing I noticed in my logs shows this:

Stopping jboss-as: .ESC[60G[ESC[0;32m OK ESC[0;39m]
Starting jboss-as: .......ESC[60G[ESC[0;32m OK ESC[0;39m]

it should look like this:
Stopping jboss-as: .[ OK ]
Starting jboss-as: .......[ OK ]

I remember when I constructed the script I put some font colors, but I already removed it
I also made a couple of check on my script and verified that all markers for the font colors are removed
whould you know what caused it?
It merely looks like you believe you removed the color attributes, but either did not or did not fully.

A thing to try is to completely comment out those log lines using "#" and then rewrite them entirely without ever adding any color attributes.

Or to leave those ones there and add newly typed ones without color attributes and you should see two log entries one potentially with the added characters and the other one correct. This would mean that there are some form of characters, likely unseen in the editor which have corrupted those lines in your script, but you can remove by deleting and re-creating those lines.

More likely you may have another copy of the script which is what you're running and the copy you've edited is not being run. A test for that is to put a very bogus or obvious line right at the top of the script, like:
Code:
#!/bin/sh
echo "TERMINATING EARLY!!"
exit 0

<rest of the script>
If your script doesn't echo that and terminate, then you've copied your script at some point to a location within your path, likely "." is not within your path, and so when you run the script, you're running another copy of it versus the one you're presently editing.

Granted whether "." is in your path or not, if you happen to be invoking the script as "./script-name.sh" from within the local edit directory, then my take is you are running your intended version.

I'm just thinking that the only reasons I can see for it outputting those unintended characters is that you're not editing the exact copy of that script that is running, or there are hidden characters still on those lines which you can eliminate by totally deleting and re-typing those lines. Otherwise, I'm stumped. Perhaps you can post that part of your script where these particular logs are located.
 
1 members found this post helpful.
  


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
bash-script: how to start the prozess one after another thomas2004ch Linux - Software 2 10-06-2011 12:42 AM
start script bash when system start,stop,reeboot, how ?? melmar Linux - General 4 12-10-2009 06:58 AM
Bash script to start another script when USB is inserted? linus72 Linux - Newbie 1 04-16-2009 05:19 AM
bash - start remote script from local script? babag Programming 7 04-06-2008 05:46 PM
Get script to start again at a certain point in the script (bash) helptonewbie Programming 11 01-11-2008 05:49 AM


All times are GMT -5. The time now is 10:02 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