11-25-2009
Assign dscl output to variable as an array
Greetings folks,
I am trying to assign the output of a dscl command (contains name<spaces>id) to a variable as an array. Currently I am piping the output into a tmp file, then reading the tmp file into an array, then parsing the array. I would like to bypass creating the tmp file portion of the code.
currently I am doing this:
----pseudo code follows----
dscl -u diradmin -P password /LDAPv3/127.0.0.1 -list /Users UniqueID > nameid.tmp
read file into array
process array values
----end pseudo code----
Is there a way to simply assign the dscl output directly to a variable as an array, e.g.
output = dscl -u diradmin -P password /LDAPv3/127.0.0.1 -list /Users UniqueID
Many thanks for your time
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I am giving a grep command, and i am getting the output. i want to store it in a variable
for eg
a = grep '12345' /dir/1/2/log.txt ( the output is number)
b= grep 'basic' /dir/1/2/log1.txt (in this case the output is character)
so how to assign the output of grep to a variable
... (1 Reply)
Discussion started by: vasikaran
1 Replies
2. Shell Programming and Scripting
I want to assign a comment to a veriable
for example my program
head -1 myfile
I want to assıgn output to a variable (1 Reply)
Discussion started by: walnut
1 Replies
3. Shell Programming and Scripting
Hi,
I work in ksh88.
I have an interective script which prompts the user for the input and returns numeric value depending on the input provided. I need to call this script inside another script and then assign the resulting output the the variable.
The call like that A=`my script` obviously... (6 Replies)
Discussion started by: aoussenko
6 Replies
4. Shell Programming and Scripting
I want to ask the user to enter an X amount of file names. I want to put those names into an array and then loop back through them to verify they are in the directory. 1st- How would I assign the value to an array and what is the correct syntax. 2nd- how would i reference that array after I... (3 Replies)
Discussion started by: tvb2727
3 Replies
5. Shell Programming and Scripting
Hi,
I have a piece of code as follows:
i=0
while read LINE
do
var = "$LINE"
i=$((i+1))
echo "${var}"
done < file
I want to assign value to the array var.
However, when i execute the script i get a error.
Please can you help me know what i am missing.
I ultimately want to... (2 Replies)
Discussion started by: sunrexstar
2 Replies
6. Shell Programming and Scripting
Hi every one.. I'm new to shell scripting... I would like to assign a single array element to a variable... Is it possible to do it....
Could any body help me.... (3 Replies)
Discussion started by: kaushik_87
3 Replies
7. Shell Programming and Scripting
I wish to assign file names with particular extention to array variables. For example if there are 5 files with .dat extention in /home/sam then i have to assign these 5 files to an array.
plz help me how to accomplish this.
Thanks in advance. (4 Replies)
Discussion started by: siteregsam
4 Replies
8. Shell Programming and Scripting
With this script i want to print the output to a specific field-number . Can anybody help?
awk 'NR=FNR{split(FILENAME,fn,"_");nr=$2;f = $1} END{for (i=1;i<=f;i++) print i,$fn=nr}' input_5.csv input_6.csvinput_5.csv
4 135
5 185
6 85
11 30input_6.csv
1 90
3 58
4 135
7 60
8 55
10... (1 Reply)
Discussion started by: sdf
1 Replies
9. Shell Programming and Scripting
is it possible to assign value to an array variable from an external file?? if yes then how??
I am using below code but its not working.
#!bin/bash
myarray < file_name
echo ${mayarray} (6 Replies)
Discussion started by: mukulverma2408
6 Replies
10. Shell Programming and Scripting
Hi Folks,
I am trying to assign a value from the command to a dynamic variable. But I am not getting the desired output.. I am sure something is wrong so i need experts advise.
There will be multiple files like /var/tmp/server_1, /var/tmp/server_2, /var/tmp/server_3, having different server... (6 Replies)
Discussion started by: ganga.dharan
6 Replies
LEARN ABOUT HPUX
cmscancl
cmscancl(1m) cmscancl(1m)
NAME
cmscancl - gather system configuration information from nodes with Serviceguard installed.
SYNOPSIS
cmscancl [-n node_name]... [-s|-o output_file]
DESCRIPTION
cmscancl is a configuration report and diagnostic tool intended only for use by HP Support Personnel. It gathers system software and hard-
ware configuration information from a list of nodes, or from all the nodes in a cluster. The information that this command displays
includes LAN device configuration, network status and interfaces, file systems, LVM configuration, link-level connectivity (HPUX only),
IPv4/IPv6 connectivity, and the data from the binary cluster configuration file. This command can be used as a troubleshooting tool or as
a data collection tool.
This command is a Perl script which gathers system configuration information by executing various OS commands or tools. It uses the cmexec
command to gather information from remote nodes.
The -n option can be used to specify a list of nodes to be scanned, the nodes to be scanned do not need to be a member of a cluster. If
the -n option is not specified, it will scan all the nodes in the local cluster.
By default, the output of this command will go to the file /tmp/scancl.out. If the file /tmp/scancl.out already exists, the old file will
be saved in /tmp/scancl.out.old.
The -o option can be used to redirect output to a specified output file. If the -o option is not specified, output will go to the default
output file /tmp/scancl.out.
The -s option can be used to direct all output to the screen, instead of to an output file.
Options
cmscancl supports the following options:
-n node_name... Specify the node(s) to be scanned. If this option is not specified and there is a cluster configured, all the
nodes in the cluster will be scanned. If this option is not specified and there is no cluster configured, only the
local node will be scanned.
-o output_file Write configuration information to a specified output file. If this option is not specified, the information will
be directed to stdout.
-s Display the configuration information to the screen only. This option cannot be used in conjunction with the -o
option.
The output from this command contains the following information:
LAN device configuration (On HP-UX, output from lanscan; On Linux, output from ifconfig)
network status and interfaces (output from netstat)
file systems (output from mount)
LVM configuration (contents of /etc/lvmtab file)
LVM physical vg information (contents of /etc/lvmpvg file)
link-level connectivity (HP-UX only)
(output from linkloop)
IPv4/IPv6 connectivity (results from ping (and ping6 on Linux))
binary configuration file data
(output from cmviewconf)
RETURN VALUE
cmscancl returns the following value:
0 Successful completion.
1 Command failed.
EXAMPLES
To gather the configuration information from node1 and node2 and to save the output in file /tmp/scancl.log:
cmscancl -n node1 -n node2 -o /tmp/myscancl.log
To gather the configuration information from all the nodes in the cluster and save the output to the file: /tmp/scancl.log:
cmscancl -o /tmp/myscancl.log
To gather the configuration information from all the nodes in the cluster and display the output on the screen:
cmscancl -s
To gather the configuration information from all the nodes in the cluster and save the output to the file /tmp/scancl.out:
cmscancl
AUTHOR
cmscancl was developed by HP.
SEE ALSO
Linux:
cmviewcl(1), mount(8), netstat(8), ping(8), ping6(8)
HP-UX:
cmviewcl(1m), lanscan(1m), linkloop(1m), mount(1m), netstat(1), ping(1m)
Requires Optional Serviceguard Software cmscancl(1m)