Sponsored Content
Top Forums Shell Programming and Scripting Saving value as default value Post 302335598 by kshji on Monday 20th of July 2009 04:41:43 AM
Old 07-20-2009
Using personal setup file ex. mysetup.txt. This works every posix-sh (ksh, bash, ...).
Code:
#!/bin/ksh
#mysetup
#use:
#mysetup -
#- use mysetup using my own defaut setup
#or
#mysetup
#- ask values and save using previous values as default

set1="sysdefault1"
set2="sysdefault2"
# always use mysetup as default if there is
[ -f $HOME/mysetup.txt ] && . $HOME/mysetup.txt

savedef()
{
   > $HOME/mysetup.txt
   # which variables to save
   for var in set1 set2
   do
        eval echo "\"$var='\$$var'\""  >> $HOME/mysetup.txt
   done
}

askvalues()
{
echo -n "set1 [$set1]:"
read Xset1
[ "$Xset1" != "" ] && set1="$Xset1"
echo -n "set2 [$set2]:"
read Xset2
[ "$Xset2" != "" ] && set2="$Xset2"
savedef
}

#######MAIN####
[ "$1" != "-" ] && askvalues

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Saving to a floppy

How do I save a file to a floppy. I mounted the drive and it is there. Everytime I try to save to the floppy, it tells me the resource is busy. Please advise. Thanks, (1 Reply)
Discussion started by: umether
1 Replies

2. Solaris

disable daylight saving

hi ... i have an E450 sun server that is running solaris 6 . i want to disable daylight savings on my server . My question is : 1) how to know that my server is running daylight savings ? 2) how to disable it ? my zoneinfo file contains the following # @(#)init.dfl 1.2 92/11/26 # #... (1 Reply)
Discussion started by: ppass
1 Replies

3. UNIX for Dummies Questions & Answers

saving from unix into pc

hi, i access unix through secure shell (SSH) from my pc running on windows. Can i save files from unix directly into windows-run pc?. e.g. vi files into notepad??? thanks alot, -a (6 Replies)
Discussion started by: alikun
6 Replies

4. Shell Programming and Scripting

saving a vi session

Apologies if this isn't quite the right thread I have a vi session and I have set a lot of tags with 'mx'. can I save this session preserving these tags so when I go back to the session I don't have to reset them all? cheers (0 Replies)
Discussion started by: ajcannon
0 Replies

5. AIX

Implement daylight saving.

Hi all We are currently using AIX 5.3, we reuquire to change the time according to the daylight saving scenario. We are using the internal clock and are not synced with ntp server. Can any one please tell me how to do that without effecting the processes running on the servers? (1 Reply)
Discussion started by: masquerer
1 Replies

6. Red Hat

Live-cd Saving changes

Hi all, firstly apologies if this is in the wrong category. I have been making livecds (fedora based) and to change eg the background i use below in the ks file. this works fine, however when i install the livecd it loses the changes. How can i make the changes so that they stay when... (5 Replies)
Discussion started by: davewilks
5 Replies

7. Shell Programming and Scripting

bashrc not saving changes

I am trying to do some changes at bashrc file located at /etc directory of my server. First I tried to edit bashrc via FTP downloaded on my pc changed it and loaded back, but it seems like changes are not reflecting. Therefore I tried to change it via putty shel using vim bashrc command. but... (4 Replies)
Discussion started by: ninadgac
4 Replies

8. Shell Programming and Scripting

Saving files

Hi all, I need to save my files at c, d or any drive location via script. Requirement. Say for example i have 10 files at location /usr/bi/ci location. 10 files naming a.ksh b,ksh c.ksh and so on I want to save the files and its content at some location (any drive on local... (4 Replies)
Discussion started by: j_panky
4 Replies

9. Solaris

Saving to usb

Greetings. I am trying to save a file to a usb from solaris 10. If I do rmformat, I see my usb, but can't find a location to tell things to save to or figure out how to save/view the files on the disk. Any help/thoughts/etc would be appreciated. Thanks! ~K (20 Replies)
Discussion started by: kuriosity_prime
20 Replies

10. Red Hat

Saving TTY settings

I have 4 digi etherlite boards that allow Wyse and VT100 terminals to connect to our network (stop laughing) :) We are switching from an older version of redhat where we have these running to: Red Hat Enterprise Linux Server release 6.5 (Santiago) I finally got them working and copied the tty... (5 Replies)
Discussion started by: mp99
5 Replies
af_sets(3)						    Attribute Filesystem (AtFS) 						af_sets(3)

NAME
af_initset, af_nrofkeys, af_setgkey, af_setaddkey, af_setrmkey, af_setposrmkey, af_sortset, af_subset, af_copyset, af_intersect, af_union, af_diff - AtFS operations on key sets SYNOPSIS
#include <atfs.h> int af_initset (Af_set *set) int af_nrofkeys (Af_set *set) int af_setgkey (Af_set *set, int position, Af_key *key) int af_setaddkey (Af_set *set, int position, Af_key *key) int af_setrmkey (Af_set *set, Af_key *key) int af_setposrmkey (Af_set *set, int position) int af_sortset (Af_set *set, char *attrname) int af_subset (Af_set *set, Af_attrs *attrbuf, Af_set *subset) int af_copyset (Af_set *source, Af_set *destination) int af_intersect (Af_set *set1, Af_set *set2, Af_set *newset) int af_union (Af_set *set1, Af_set *set2, Af_set *newset) int af_diff (Af_set *set1, Af_set *set2, *Af_set newset) DESCRIPTION
Sets in AtFS are ordered collections of keys. The structure of sets is the following typedef struct { int af_nkeys; int af_setlen; Af_key *af_klist; } Af_set; The list of keys in a set is a linear list, residing in allocated memory. The list has no holes, so that positions 0 through af_nkeys-1 are occupied with valid keys. Set functions returning a set require a pointer to an empty set structure as argument. af_initset initializes a set. af_nrofkeys returns the number of valid keys in the given set. af_setgkey delivers the filekey, stored at position position in the identified set. The result is passed in the buffer key. Typically you use af_setgkey to run through a set and perform a special action on each key. The following code sequence does this job: Af_key key; Af_set set; af_initset (&set); ... for (i = 0; i < af_nrofkeys (&set); i++) { af_setgkey (&set, i, &key); /* process key */ ... } af_setaddkey introduces a new filekey to an existing set at the given position. All following keys are moved back by one position. The constant AF_LASTPOS given as position argument leads to adding the new filekey at the end of the set. af_setrmkey (af_setposrmkey) removes the given filekey (the filekey at position position) from the specified set. Holes generated by delet- ing single keys from a set are eliminated by condensing the set. All following keys are moved one position forth in the set. af_sortset sorts a given set of object keys by the values of the named attribute. The set is sorted in increasing order. Increasing order means, that the lowest value occurs first in the set. Af_user structures are compared by username first and by userdomain, if the names are equal (user host will not be taken into account). Version numbers are ordered in natural order, busy versions first. In atfs.h you can find a list of attribute names naming the standard attributes. All other attribute names are presumed to be user defined attributes. While sorting by the values of an user defined attribute, all ASOs that do not have the named attribute are added at the end of the resulting (sorted) set. Sorting of user defined attributes with multiple values bases on simple text comparison with the order of the values taken as it is. The length of the given attribute name is limited. This limit is defined by the constant AF_UDANAMLEN in atfs.h. af_subset does a retrieve operation (similar to af_find - manual page af_retrieve(3)) on a given set of object keys. Af_subset takes an attribute buffer (attrbuf) with all desired attributes set to an appropriate value as argument. The attribute buffer should be initialized by af_initattrs (manual page af_retrieve(3)) beforehand. af_subset returns it's result in a new set, the original set remains unchanged. af_copyset for copying sets (really! =:-). af_intersect, af_union and af_diff build intersections, unions, and differences between two sets. The result is a new set, where all keys taken from the first argument set (set1) occur first, and the keys from the second argument set (set2) afterwards. You may gibe one of set1 or set2 as resultset. In that case, the original set get lost and is dropped implicitely. Sets generated by af_copyset, af_subset, af_intersect, af_union, or af_diff should be released by af_dropset as soon as they are not used any longer. SEE ALSO
af_retrieve(3) DIAGNOSTICS
Upon error, -1 or a nil pointer (depending on the return type) is returned and af_errno is set to the corresponding error number. AtFS-1.71 Fri Jun 25 14:33:20 1993 af_sets(3)
All times are GMT -4. The time now is 11:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy