From owner-freebsd-questions@FreeBSD.ORG Fri Nov 25 07:45:41 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A37E316A41F for ; Fri, 25 Nov 2005 07:45:41 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from nic.ach.sch.gr (nic.sch.gr [194.63.238.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 25BED43D72 for ; Fri, 25 Nov 2005 07:45:33 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: (qmail 1377 invoked by uid 207); 25 Nov 2005 07:45:30 -0000 Received: from keramida@ceid.upatras.gr by nic by uid 201 with qmail-scanner-1.21 (sophie: 3.04/2.30/3.97. Clear:RC:1(81.186.64.118):. Processed in 0.837037 secs); 25 Nov 2005 07:45:30 -0000 Received: from clnt-68dim-patras.ach.sch.gr (HELO flame.pc) ([81.186.64.118]) (envelope-sender ) by nic.sch.gr (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 25 Nov 2005 07:45:19 -0000 Received: from flame.pc (flame [127.0.0.1]) by flame.pc (8.13.4/8.13.4) with ESMTP id jAP7iN1Z001658; Fri, 25 Nov 2005 09:44:23 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by flame.pc (8.13.4/8.13.4/Submit) id jAP7iNx9001657; Fri, 25 Nov 2005 09:44:23 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Fri, 25 Nov 2005 09:44:23 +0200 From: Giorgos Keramidas To: user Message-ID: <20051125074423.GB1567@flame.pc> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Cc: freebsd-questions@freebsd.org Subject: Re: how do I feed a script conf file variables on the command line ? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Nov 2005 07:45:41 -0000 On 2005-11-25 02:11, user wrote: > Ok, let's say I have a shell script named script.sh, and > script.sh sucks in a file /etc/file.conf that contains nothing > but variable declarations like: > > SETTING1=setting1 > SETTING2=setting2 > > and so on. Very simple. > > My question is, what if I want to feed the script a setting on > the command line ? > > Normally I run the script: > > script.sh -x -v -e -r > > and it looks for /etc/file.conf and sucks in all the variables. > > But I want to: > > script.sh -x -v -e -r SETTING1='setting1' > > for some reason this is not working. I am in the FreeBSD csh > shell when I attempt this (FWIW). > > I just want to be able to quickly bypass the conf file, using a > single command line. Try env(1). env SETTING1='setting1' sh script.sh This should work much better. In fact, it's the same trick I use in my local networking setup scripts. Instead of hard-coding everything in /etc/rc.conf, I have something like this: flame# cat -n /root/netstart-home.sh 1 # 2 # Set up network interfaces for my home network. 3 # 4 5 export ifconfig_ath0="DHCP ssid "gker" \ 6 wepmode on weptxkey 1 wepkey '1:0xXXXXXXXXXXXXXXXXXXXXXXXXXX'" 7 export defaultrouter="192.168.1.2" 8 9 # 10 # Make sure the bge0 interface is brought down and then up again, 11 # with the new IP address. 12 # 13 /etc/rc.d/netif stop bge0 14 /etc/rc.d/netif stop ath0 15 /etc/rc.d/netif start ath0 You can see around lines 5-7 that I'm setting stuff in the environment, which will be picked up by the /etc/rc.d/netif system script. - Giorgos