How to redirect the messages from the script to console in Linux?
if i login with root credentials @12.36.34.123 with passwd
username:root
passwd:abc
once i login into linux pc on console the above messages should be availble like below: what coomand i need to use in linux to display the messages in consloe from the script ?
output:
:/ #
service not started
Please check the start.sh file or manuly start the service
if i login with root credentials @12.36.34.123 with passwd
username:root
passwd:abc
once i login into linux pc on console the above messages should be availble like below: what coomand i need to use in linux to display the messages in consloe from the script ?
output:
Didn't you get some output from bash like?:
Where is the variable start defined? (Did you intend to say start.sh instead of $start.sh?)
There has to be a space between /user/script/$start.sh (or /user/script/start.sh) and ].
yes , i am getting the output when i run my script : my script is working and it is giving the below output and cron job i sheduled every week.
output:
the problem is once the script run's some time it will start service or it will tell service is not started.
my requirement is whenever i login that linux the output messages should be print in console. what command i need to redirect the output to console .
whenever i login the linux i want to see the output
or
---------- Post updated at 03:07 AM ---------- Previous update was at 01:27 AM ----------
how to get the outout from script to console.
i am running one script msg.sh using cron job every suday midnight. as soon as i logged in i want to see the staus is service started or service failed on console.
what command i need to add to script ?
msg.sh
if i login with root credentials @12.36.34.123 with passwd
i once i logged in linux service started or service failed ( out put of the script ) should be printed on console.
how to check or how to extract messages in linux from var/log/message to current console
Last edited by Don Cragun; 11-12-2014 at 01:54 PM..
Reason: Add CODE and ICODE tags again.
Getting your act together BEFORE you post would definitely help us help you.
Trying to boil down what you said:
You have a script, verified it is well-behaved when started from the command line, run it from cron at Sunday midnight and want to see its output when logging in next time?
Per default, cron will mail a job's output to the respective user. So, you could check your mails at login and find the desired output.
If you want it displayed at login, have cron write a logfile, eventually to your HOME directory, and in your shell's startup/login script, use e.g. cat or more / less to output it to your terminal (which I guess is what you mean by "console").
What will show up in /var/log/messages related to your job will be sth like
unless you use e.g. logger in your script to explicitely log it to the system logs.
You are already doing 'send the msg on console/terminal'.
In which case, you could execute this 'msg.sh' script at login.
For a bash based linux, this could be in: $HOME/.bashrc (note the . before the name)
Or do you ment to write to the logs?
Which in case of a regular service should already be done - see journalctl (1) for more details.
Otherwise you could always redirect your output to a file, which you can read at any time later.
To overwrite existing content:
To append:
Hope this helps
Please look at post #2 in this thread. You seem to have ignored everything I asked.
Change your script to the following and run it from the command line (not from cron):
Note that I added the space in your [ command that I told you had to add before. Without that space, your syntax error guarantees that the then clause in your if statement will NEVER be executed.
Then notice that there is absolutely nothing in your script that will start anything! You check to see if a file exists (and, by convention, it looks like that file is a shell script), but if that file does exist, there is no attempt to execute it. If you were ever to execute the command:
it would be reporting a lie. This script never makes any attempt to start anything even after the syntax error is corrected!
Hi there,
How do I enter command to the interactive console.
I was able to do it via the first line. What if I have more lines to input into the interactive console from line 3 onwards. Is there a more easier way?
(echo -e "load openvas" ; echo -e "openvas_help") | msfconsole
... (4 Replies)
how to get the outout from script to console.
i am running one script msg.sh using cron job every suday midnight. as soon as i logged in i want to see the staus is service started or service failed on console.
what command i need to add to script ?
msg.sh
#!/bin/bash
if
then
echo... (1 Reply)
Hello,
Oracle PDF reports run only when you run the command
# xhost +
from the console,
but if you run from the xmanager session , then report doesn't work
running from windows pc using xmanager
# xhost +
access control disabled, clients can connect from any host
# echo... (7 Replies)
Hi,
I'd like to redirect the STDOUT output from my script to a file and simultaneously display it at a console.
I've tried this command:
myscript.sh | tail -f
However, it doesn't end after the script finishes running
I've also tried this:
myscript.sh | tee ~/results.txt
But it writes... (3 Replies)
Hi
can anyone tell me how to redirect the ouput of a cvs command to a file as well as the console?
i tried using
cvs add <filename> | tee logFile
cvs add <filename> 2>logFile 2>&1
All i could get is only on console or on file.
Please help
Thanks (2 Replies)
:confused:Hi
This was installed on the Linux box a few weeks back by a guy that no longer works for us. All worked fine until last week. Now when we connect its just a blank screen with no icons.
I get a whole bunch of errors when starting the service too:
Tue Feb 23 14:29:45 2010
... (1 Reply)
Is there a utility built into Solaris that will allow me to see console messages from a tty?
I've done a search and see that this is possible through software like ILOM, but I'm looking for a method to do this with built in utilities.
For example, on AIX, I can use swcons `tty` (6 Replies)
How to redirect the output to multiple files without putting on console
I tried tee but it writes to STDOUT , which I do not want.
Test.sh
------------------
#!/bin/ksh
echo "Hello " tee -a file1 file2
----------------------------
$>./Test.sh
$>
Expected output:
-------------------... (2 Replies)
I'm trying to write a python wrapper around wget to show the progress bar on a gui application. Wget gives you a progress bar on command line, but how would I pipe that to some "tty" that's really just a variable I read, or am I going about it all wrong? When I try to just redirect the output to a... (1 Reply)