Good evening,
I am very inexperienced in writing in csh so please forgive me if this post is a little amateur.
Let's suppose I have some directories located here:
/var/adm/my_users/
Each directory is a different user name, e.g., jane.doe@some-domain.com and contains a file called 'group'.
The group file has one line denoting primary group membership, e.g., primary:great_friends
Currently I have a script that will retrieve a username and assign it to a database value, i.e., 'USER_NAME_FIELD' to each associated file.
Here is the action part of my script:
/usr/etc/myprogramme/actions/setdatafield/setdatafield -u $vuser -fid $vfid -k USER_NAME_FIELD -val $vuser -flags 256 -val2
This works fine; the question is, can I modify my script to also read the user's group file and assign this to the database field GROUP_FIELD?
Once the user name field has been set, I then need to read the group file and run the action again.
If I've thought this out correctly, the reading part would be:
/var/adm/webnative/$vuser/group
Obviously we only want the value after the colon, i.e., primary:great_friends
And my new action would be:
/usr/etc/myprogramme/actions/setdatafield/setdatafield -u $vuser -fid $vfid -k GROUP_FIELD -val $vuser -flags 256 -val2
Below is the script I am using; can anyone help me amend the syntax to incorporate the above namely the read and the action?
Best regards
#!/bin/csh -f
# setdatafieldtouser custom action
#
# This is a custom action that calls setdatafield to set a keyword
# to the username of the user that triggered the action.
#
#
# Set the Usage message.
set USAGE = "usage: $0 -u <user> -fid <file id>"
# Check argument count to confirm correct usage.
if ($#argv <= 3) then
echo $USAGE
exit -1
endif
# Parse Args
@ i = 1
while ($i < $#argv)
switch($argv[$i])
case "-fid":
@ i++
set vfid = `echo "$argv[$i]"`
breaksw
case "-u":
@ i++
set vuser = `echo "$argv[$i]"`
breaksw
default:
breaksw
endsw
@ i++
end #while
/usr/etc/myprogramme/actions/setdatafield/setdatafield -u $vuser -fid $vfid -k USER_NAME_FIELD -val $vuser -flags 256 -val2
exit 0
I am very inexperienced in writing in csh so please forgive me if this post is a little amateur.
Let's suppose I have some directories located here:
/var/adm/my_users/
Each directory is a different user name, e.g., jane.doe@some-domain.com and contains a file called 'group'.
The group file has one line denoting primary group membership, e.g., primary:great_friends
Currently I have a script that will retrieve a username and assign it to a database value, i.e., 'USER_NAME_FIELD' to each associated file.
Here is the action part of my script:
/usr/etc/myprogramme/actions/setdatafield/setdatafield -u $vuser -fid $vfid -k USER_NAME_FIELD -val $vuser -flags 256 -val2
This works fine; the question is, can I modify my script to also read the user's group file and assign this to the database field GROUP_FIELD?
Once the user name field has been set, I then need to read the group file and run the action again.
If I've thought this out correctly, the reading part would be:
/var/adm/webnative/$vuser/group
Obviously we only want the value after the colon, i.e., primary:great_friends
And my new action would be:
/usr/etc/myprogramme/actions/setdatafield/setdatafield -u $vuser -fid $vfid -k GROUP_FIELD -val $vuser -flags 256 -val2
Below is the script I am using; can anyone help me amend the syntax to incorporate the above namely the read and the action?
Best regards
#!/bin/csh -f
# setdatafieldtouser custom action
#
# This is a custom action that calls setdatafield to set a keyword
# to the username of the user that triggered the action.
#
#
# Set the Usage message.
set USAGE = "usage: $0 -u <user> -fid <file id>"
# Check argument count to confirm correct usage.
if ($#argv <= 3) then
echo $USAGE
exit -1
endif
# Parse Args
@ i = 1
while ($i < $#argv)
switch($argv[$i])
case "-fid":
@ i++
set vfid = `echo "$argv[$i]"`
breaksw
case "-u":
@ i++
set vuser = `echo "$argv[$i]"`
breaksw
default:
breaksw
endsw
@ i++
end #while
/usr/etc/myprogramme/actions/setdatafield/setdatafield -u $vuser -fid $vfid -k USER_NAME_FIELD -val $vuser -flags 256 -val2
exit 0