log in ifup


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting log in ifup
# 1  
Old 03-29-2009
log in ifup

I have a little script in the /etc/network/if-up.d (debian). It should do something and write the output to a log file. But it doesn't seem to work.

Code:
ifup wlan0 dosomething >> /var/log/dosomething.log

I would like to add the date to the output, can somebody help me please?
Thanks!
# 2  
Old 03-29-2009
Quote:
Originally Posted by borobudur
I have a little script in the /etc/network/if-up.d (debian). It should do something and write the output to a log file. But it doesn't seem to work.

What does "doesn't seem to work" mean? What does happen? What do you want to happen?
Quote:

Code:
ifup wlan0 dosomething >> /var/log/dosomething.log

I would like to add the date to the output, can somebody help me please?
Thanks!

Code:
date +"%Y-%m-%d_%H:%M:%S $(ifup wlan0 dosomething)" >> /var/log/dosomething.log

# 3  
Old 03-30-2009
Hey, thanks for your help!

With your line, it just writes the date into the log file. No output of my dosomething program.

I tested my program; it works:
  • This writes the output of my program to the standard output (the terminal)
    Code:
    dosomething

  • This writes it to the log file
    Code:
    dosomething >> /var/log/dosomething.log

  • This writes it correctly to the standard output
    Code:
    date +"%Y-%m-%d_%H:%M:%S $(dosomething)"

  • This writes just the date (%Y-%m-%d_%H:%M:%S) to the log file (running as a script in /etc/network/if-up.d)
    Code:
    date +"%Y-%m-%d_%H:%M:%S $(ifup wlan0 dosomething)" >> /var/log/dosomething.log

    I don't know if my program was running.
Any idea?

Last edited by borobudur; 03-30-2009 at 05:30 PM..
# 4  
Old 03-30-2009
Code:
date=$( date +"%Y-%m-%d_%H:%M:%S" )
something=$(dosomething)
if [ -z "$something" ] 
then
   echo "dosomething produced no output" >&2
   exit 1
fi
printf "%s %s\n" "$date" "$something" >> /var/log/dosomething.log

# 5  
Old 03-31-2009
Thanks but why ifup wlan0 doesn't work?
# 6  
Old 03-31-2009
Quote:
Originally Posted by borobudur
Thanks but why ifup wlan0 doesn't work?

What does "doesn't work" mean?

What does happen?

What, exactly, did you try?
# 7  
Old 03-31-2009
Well, when the connection to the wlan is there I would expect that my program is running. The program works and gives output but it looks like not with ifup.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Log all the commands input by user at real time in /var/log/messages

Below is my script to log all the command input by any user to /var/log/messages. But I cant achieve the desired output that i want. PLease see below. function log2syslog { declare COMMAND COMMAND=$(fc -ln -0) logger -p local1.notice -t bash -i -- "$USER:$COMMAND" } trap... (12 Replies)
Discussion started by: invinzin21
12 Replies

2. Shell Programming and Scripting

Log search and mail it if the log is updated before 24 hours from the current time

Hi , We have around 22 logs , each has different entries. I have to automate this using shell script. The ideas which am sharing is given below 1) We use only TAIL -100 <location and name of the log> Command to check the logs. 2) We want to check whether the log was updated before 24... (13 Replies)
Discussion started by: Kalaihari
13 Replies

3. Shell Programming and Scripting

Check log file size every 10 minute. Alert if log not update

How to check log size every 10min. by script (can use crontab) if log size not change with alert "Log not update" Base run on SunOS 5.8 Generic_Virtual sun4u sparc SUNW,SPARC-Enterprise logFiles="log1.log log2.log" logLocation="/usr/home/test/log/" Out put. Tue Jan 31... (3 Replies)
Discussion started by: ooilinlove
3 Replies

4. Red Hat

Dual NICs - When I 'ifup eth1' it replaces eth0

I've got an issue with a VMWare server running RHEL 6.3 that has dual E1000 NICs. I have configured the cards as I would normally do in /etc/sysconfig/network-scripts as ifcfg-eth0 and ifcfg-eth1. I can execute ifup eth0 and bring the interface up quite happily, however when I execute ifup eth1 it... (2 Replies)
Discussion started by: phaedrus
2 Replies

5. Shell Programming and Scripting

Monitor log entries in log files with no Date format? - Efficient logcheck?

is there a way to efficiently monitor logfiles that do not have a date or time format? i have several logs on several different servers that need to be monitored. but i realized writing a script for this would be very complex and time consuming giving the variety of things i need to check for i.e.... (2 Replies)
Discussion started by: SkySmart
2 Replies

6. HP-UX

Script to monitor /var/opt/resmon/log/event.log file

AM in need of some plugin/script that can monitor HP-UX file "/var/opt/resmon/log/event.log" . Have written a scrip in sh shell that is working fine for syslog.log and mail.log as having standard format, have interrogated that to Nagios and is working as I required . But same script failed to... (3 Replies)
Discussion started by: Shirishlnx
3 Replies

7. Shell Programming and Scripting

How can view log messages between two time frame from /var/log/message or any type of log files

How can view log messages between two time frame from /var/log/message or any type of log files. when logfiles are very big and especially many messages with in few minutes, I would like to display log messages between 5 minute interval. Could you pls give me the command? (1 Reply)
Discussion started by: johnveslin
1 Replies

8. Shell Programming and Scripting

Perl's buffered I/O is causing me to miss latest log file entries in log colorizer. How to fix?

I've been finding myself using a log file colorizer written in perl to reformat and colorize the output from many different programs. Mainly, however, I use it to make the output from "tail -f" commands more readable. The base perl script I use is based on "colorlogs.pl" available from the... (1 Reply)
Discussion started by: rcsteiner
1 Replies

9. Red Hat

ifconfig , ifdown, ifup

hi there the ethernet wire was out of the pc when the system started. #ifconfig #ifconfig -a i did not get any ip for eth0. i plug the cable into the pc #ifdown eth0 #ifup eth0 now the ip address is assigned to eth0 Question is : IS this right way to bring ethernet down... (2 Replies)
Discussion started by: dplinux
2 Replies

10. UNIX for Advanced & Expert Users

When is 'ifup' really done?

I have been looking in the scripts for interface management, in an effort to kick off a script of my own on any "significant network event" (I will qualify that in a bit) I managed to add a check to tell netplugd to run my script every time there is a hot-plug event. Now I need to make it so my... (0 Replies)
Discussion started by: jjinno
0 Replies
Login or Register to Ask a Question