Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Capping output redirection log file length Post 302361244 by joemommasfat on Monday 12th of October 2009 06:09:55 PM
Old 10-12-2009
Capping output redirection log file length

I am trying to write a script which will output notifications to a logfile, but I would like to cap the logfile to, let's say, 200 lines.

Specifically I am using custom firmware, DD-wrt, on my router and I am implementing a script to connect to my work vpn. I have a loop that pings a computer behind the vpn, and then sleeps for a minute before doing it again. If the ping fails, I have it write a brief message to a logfile. There is no real storage on the router, so everything is held in memory. If my log file gets too large, I will crash my router. Is there a way to make my logfile remove the top line when appending to the bottom, if the file is more than 200 lines. Currently I just append with '>>', but there must be a smarter way.

The relevant parts of the script are below.

Code:
#!/bin/sh

pingtest () {
 ping -q -c1 $1 >> /dev/null
 echo "$?"
}

vpn_keepalive_host1="192.168.###.###"

while [ 1 ]; do
  if [ "`pingtest $vpn_keepalive_host1`" == "0" ]; then
    sleep 60
  else
    echo `date` "$vpn_keepalive_host1 unreachable" >> /tmp/etc/vpnc/Status.$vpn_keepalive_host1

    #reconnect to vpn
    vpnc-disconnect
    vpnc /tmp/etc/vpnc/vpn.conf --dpd-idle 0
  fi
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

creating a fixed length output from a variable length input

Is there a command that sets a variable length? I have a input of a variable length field but my output for that field needs to be set to 32 char. Is there such a command? I am on a sun box running ksh Thanks (2 Replies)
Discussion started by: r1500
2 Replies

2. UNIX for Dummies Questions & Answers

Redirection of output to a log file

Apologies for the trivial nature of this question but I cannot seem to get a simple re direct to a log file to work Step 1 touch log.txt at -f batch.sh now >> log.txt I am trying to get the batch.sh contents into the log file Manny Thanks (8 Replies)
Discussion started by: JohnCrump
8 Replies

3. UNIX for Dummies Questions & Answers

Convert a tab delimited/variable length file to fixed length file

Hi, all. I need to convert a file tab delimited/variable length file in AIX to a fixed lenght file delimited by spaces. This is the input file: 10200002<tab>US$ COM<tab>16/12/2008<tab>2,3775<tab>2,3783 19300978<tab>EURO<tab>16/12/2008<tab>3,28523<tab>3,28657 And this is the expected... (2 Replies)
Discussion started by: Everton_Silveir
2 Replies

4. Shell Programming and Scripting

Remote server file output redirection

Hi, I want ssh to the remote server and then execute ls and redirect the output to the file in remote server itself like ssh root@$server `ls /var/log/users.txt > root@$server:/home/users.txt` Can you please let me know the correct syntax for it. Thanks in advance (2 Replies)
Discussion started by: mohitmoudgil
2 Replies

5. UNIX for Dummies Questions & Answers

Output file redirection

Suppose I have a file named a When I write cat a>a The following error message is displayed cat: a: input file is output file and my file a is truncated to zero size. Also the exit status of the last command is 1 Can someone tell me what actually happens when I do so? (1 Reply)
Discussion started by: aagajaba
1 Replies

6. Shell Programming and Scripting

awk output redirection to file

I have a system stat command running which generates data after 5 sec or so. I pass this data to awk and do some calculation to present the data differently. Once done now I want to pass this data to file as and when generated but doesn't work..unless the first command completes successfully.... (6 Replies)
Discussion started by: learnscript
6 Replies

7. Shell Programming and Scripting

output redirection to existing file question

So I have a existing file that I used the uniq command on and I need to save the output to the same file without changing the file name. I have tried $ uniq filename > filename then when I cat the file it then becomes blank like there is nothing inside. any help would be much appreciated... (0 Replies)
Discussion started by: drew211
0 Replies

8. Shell Programming and Scripting

Redirection of ls -l output

Hi I am making a script where i want to redirect the output of ls -l to a file Example #ls -l fil1.txt > /opt/temp/a.txt ac: No such file or directory I want to capture output of this command like here output is ac: No such file or directory can anyone help (4 Replies)
Discussion started by: anish19
4 Replies

9. Shell Programming and Scripting

Output redirection of c binary file to a file in shell script is failing

I am struck up with a problem and that is with output redirection. I used all the ways for the redirection of the output of c binary to a file, still it is failing. Here are the different ways which I have used: ./a.out | tee -a /root/tmp.txt 2>&1 ./a.out | tee -a /root/tmp.txt 1>&1 ./a.out |... (2 Replies)
Discussion started by: Maya29988
2 Replies

10. Shell Programming and Scripting

Command output redirection to file issues

Hi, I have a peculiar issue w.r.t redirecting the command output to a file when using loop. I am redirecting command output to same file in a series of if condition statements, but if one block of if condition statement writes the log to the file , the subsequent block of if condition... (7 Replies)
Discussion started by: ananan
7 Replies
VPNC(8) 						  System Administration Utilities						   VPNC(8)

NAME
vpnc - client for Cisco VPN3000 Concentrator, IOS and PIX SYNOPSIS
vpnc [--version] [--print-config] [--help] [--long-help] [options] [config files] DESCRIPTION
This manual page documents briefly the vpnc and vpnc-disconnect commands. vpnc is a VPN client for the Cisco 3000 VPN Concentrator, creating a IPSec-like connection as a tunneling network device for the local system. It uses the TUN/TAP driver in Linux kernel 2.4 and above and device tun(4) on BSD. The created connection is presented as a tunneling network device to the local system. OBLIGATORY WARNING: the most used configuration (XAUTH authentication with pre-shared keys and password authentication) is insecure by design, be aware of this fact when you use vpnc to exchange sensitive data like passwords! The vpnc daemon by itself does not set any routes, but it calls vpnc-script to do this job. vpnc-script displays a connect banner. If the concentrator supplies a network list for split-tunneling these networks are added to the routing table. Otherwise the default-route will be modified to point to the tunnel. Further a host route to the concentrator is added in the later case. If the client host needs DHCP, care must be taken to add another host route to the DHCP-Server around the tunnel. The vpnc-disconnect command is used to terminate the connection previously created by vpnc and restore the previous routing configuration. CONFIGURATION
The daemon reads configuration data from the following places: o command line options o config file(s) specified on the command line o /etc/vpnc/default.conf o /etc/vpnc.conf o prompting the user if not found above vpnc can parse options and configuration files in any order. However the first place to set an option wins. configuration filenames which do not contain a / will be searched at /etc/vpnc/<filename> and /etc/vpnc/<filename>.conf. Otherwise <filename> and <filename>.conf will be used. If no configuration file is specified on the command-line at all, both /etc/vpnc/default.conf and /etc/vpnc.conf will be loaded. OPTIONS
The program options can be either given as arguments (but not all of them for security reasons) or be stored in a configuration file. --gateway <ip/hostname> IP/name of your IPSec gateway conf-variable: IPSec gateway <ip/hostname> --id <ASCII string> your group name conf-variable: IPSec ID <ASCII string> (configfile only option) your group password (cleartext) conf-variable: IPSec secret <ASCII string> (configfile only option) your group password (obfuscated) conf-variable: IPSec obfuscated secret <hex string> --username <ASCII string> your username conf-variable: Xauth username <ASCII string> (configfile only option) PIN for Nortel Two-Factor Authentication conf-variable: Xauth PIN <ASCII string> (configfile only option) your password (cleartext) conf-variable: Xauth password <ASCII string> (configfile only option) your password (obfuscated) conf-variable: Xauth obfuscated password <hex string> --domain <ASCII string> (NT-) Domain name for authentication conf-variable: Domain <ASCII string> --xauth-inter enable interactive extended authentication (for challenge response auth) conf-variable: Xauth interactive --vendor <cisco/netscreen/nortel> vendor of your IPSec gateway Default: cisco conf-variable: Vendor <cisco/netscreen/nortel> --natt-mode <natt/none/force-natt/cisco-udp/nortel-udp> Which NAT-Traversal Method to use: o natt -- NAT-T as defined in RFC3947 o none -- disable use of any NAT-T method o force-natt -- always use NAT-T encapsulation even without presence of a NAT device (useful if the OS captures all ESP traf- fic) o cisco-udp -- Cisco proprietary UDP encapsulation, commonly over Port 10000 o nortel-udp -- Nortel proprietary UDP encapsulation Note: cisco-tcp encapsulation is not yet supported Default: natt conf-variable: NAT Traversal Mode <natt/none/force-natt/cisco-udp/nortel-udp> --script <command> command is executed using system() to configure the interface, routing and so on. Device name, IP, etc. are passed using enviroment variables, see README. This script is executed right after ISAKMP is done, but before tunneling is enabled. It is called when vpnc terminates, too Default: /etc/vpnc/vpnc-script conf-variable: Script <command> --dh <dh1/dh2/dh5> name of the IKE DH Group Default: dh2 conf-variable: IKE DH Group <dh1/dh2/dh5> --pfs <nopfs/dh1/dh2/dh5/server> Diffie-Hellman group to use for PFS Default: server conf-variable: Perfect Forward Secrecy <nopfs/dh1/dh2/dh5/server> --enable-1des enables weak single DES encryption conf-variable: Enable Single DES --enable-no-encryption enables using no encryption for data traffic (key exchanged must be encrypted) conf-variable: Enable no encryption --nortel-client-id <list/0-65535/ASCII string> Nortel Client version ID sent during connection. Use "list" to print allowed values. Default: V04_15 conf-variable: Nortel Client ID <list/0-65535/ASCII string> --application-version <ASCII string> Application Version to report. Note: Default string is generated at runtime. Default: Cisco Systems VPN Client 0.5.3:Linux conf-variable: Application version <ASCII string> --ifname <ASCII string> visible name of the TUN/TAP interface conf-variable: Interface name <ASCII string> --ifmode <tun/tap> mode of TUN/TAP interface: o tun: virtual point to point interface (default) o tap: virtual ethernet interface Default: tun conf-variable: Interface mode <tun/tap> --debug <0/1/2/3/99> Show verbose debug messages o 0: Do not print debug information. o 1: Print minimal debug information. o 2: Show statemachine and packet/payload type information. o 3: Dump everything exluding authentication data. o 99: Dump everything INCLUDING AUTHENTICATION data (e.g. PASSWORDS). conf-variable: Debug <0/1/2/3/99> --no-detach Don't detach from the console after login conf-variable: No Detach --pid-file <filename> store the pid of background process in <filename> Default: /var/run/vpnc/pid conf-variable: Pidfile <filename> --local-addr <ip/hostname> local IP to use for ISAKMP / ESP / ... (0.0.0.0 == automatically assign) Default: 0.0.0.0 conf-variable: Local Addr <ip/hostname> --local-port <0-65535> local ISAKMP port number to use (0 == use random port) Default: 500 conf-variable: Local Port <0-65535> --udp-port <0-65535> Local UDP port number to use (0 == use random port). This is only relevant if cisco-udp nat-traversal is used. This is the _local_ port, the remote udp port is discovered automatically. It is especially not the cisco-tcp port. Default: 10000 conf-variable: Cisco UDP Encapsulation Port <0-65535> --dpd-idle <0,10-86400> Send DPD packet after not receiving anything for <idle> seconds. Use 0 to disable DPD completely (both ways). Default: 300 conf-variable: DPD idle timeout (our side) <0,10-86400> --non-inter Don't ask anything, exit on missing options conf-variable: Noninteractive --auth-mode <default/cert/psk/hybrid/username/token/PIN-token/token-SW/gpassword> Authentication mode: o default: maps to vendor specific default mode o cert: server + client certificate (not implemented yet) o psk: Cisco pre-shared key (default for Cisco) o hybrid: Cisco server certificate + xauth (if built with openssl support) o username: Nortel User Name and Password Authentication o token: Nortel Group Security - Response Only Token - Use Passcode (default for Nortel) o PIN-token: Nortel Group Security - Response Only Token - Use Two-Factor Card o token-SW: Nortel Group Security - Response Only Token - Use SoftID Software (not implemented yet) o gpassword: Nortel Group Security - Group Password Authentication Default: default conf-variable: IKE Authmode <default/cert/psk/hybrid/username/token/PIN-token/token-SW/gpassword> --ca-file <filename> filename and path to the CA-PEM-File conf-variable: CA-File <filename> --ca-dir <directory> path of the trusted CA-Directory Default: /etc/ssl/certs conf-variable: CA-Dir <directory> --target-network <target network/netmask> Target network in dotted decimal or CIDR notation Default: 0.0.0.0/0.0.0.0 conf-variable: IPSEC target network <target network/netmask> --print-config Prints your configuration; output can be used as vpnc.conf FILES
/etc/vpnc.conf /etc/vpnc/default.conf The default configuration file. You can specify the same config directives as with command line options and additionaly IPSec secret and Xauth password both supplying a cleartext password. Scrambled passwords from the Cisco configuration profiles can be used with IPSec obfuscated secret and Xauth obfuscated password. See EXAMPLES for further details. /etc/vpnc/*.conf vpnc will read configuration files in this directory when the config filename (with or without .conf) is specified on the command line. EXAMPLES
This is an example vpnc.conf with pre-shared keys: IPSec gateway vpn.example.com IPSec ID ExampleVpnPSK IKE Authmode psk IPSec secret PskS3cret! Xauth username user@example.com Xauth password USecr3t And another one with hybrid authentication (requires that vpnc was built with openssl support): IPSec gateway vpn.example.com IPSec ID ExampleVpnHybrid IKE Authmode hybrid CA-Dir /etc/vpnc or CA-File /etc/vpnc/vpn-example-com.pem IPSec secret HybS3cret? Xauth username user@example.com Xauth password 123456 The lines begin with a keyword (no leading spaces!). The values start exactly one space after the keywords, and run to the end of line. This lets you put any kind of weird character (except CR, LF and NUL) in your strings, but it does mean you can't add comments after a string, or spaces before them. In case the the CA-Dir option is used, your certificate needs to be named something like 722d15bd.X, where X is a manually assigned number to make sure that files with colliding hashes have different names. The number can be derived from the certificate file itself: openssl x509 -subject_hash -noout -in /etc/vpnc/vpn-example-com.pem See also the --print-config option to generate a config file, and the example file in the package documentation directory where more advanced usage is demonstrated. Advanced features like manual setting of multiple target routes and disabling /etc/resolv.conf rewriting is documented in the README of the vpnc package. TODO
Certificate support (Pre-Shared-Key + XAUTH is known to be insecure). Further points can be found in the TODO file. AUTHOR
This man-page has been written by Eduard Bloch <blade(at)debian.org> and Christian Lackas <delta(at)lackas.net>, based on vpnc README by Maurice Massar <vpnc(at)unix-ag.uni-kl.de>. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 any later version published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. SEE ALSO
pcf2vpnc(1), cisco-decrypt(1), ip(8), ifconfig(8), route(1), http://www.unix-ag.uni-kl.de/~massar/vpnc/ vpnc version 0.5.3 July 2010 VPNC(8)
All times are GMT -4. The time now is 06:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy