Sponsored Content
Top Forums Shell Programming and Scripting How to read each line from input file, assign variables, and echo to output file? Post 302893357 by Scottie1954 on Tuesday 18th of March 2014 06:30:19 PM
Old 03-18-2014
Thanks, Jedi Master and Chubler_XL. Both answers worked.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk/shell question: Read from file and assign to variables.

Is anyone able to help with writing a program that will do the following: 1. Read the contents of a file, line by line, and on each line, assign each of the two columns to a shell variable. 2. perform an action on the variables 3. Read the next line. Here is what I've gotten so far. ... (3 Replies)
Discussion started by: akbar
3 Replies

2. Shell Programming and Scripting

how can i read text file and assign its values to variables using shell

Hello, I have a cat.dat file, i would like shell to read each 3 lines and set this 3 lines to 3 different variables. my cat.dat is: 11 12 +380486461001 12 13 +380486461002 13 14 +380486461003 i want shell to make a loop and assign 1st line to student_id, 2nd line to... (4 Replies)
Discussion started by: rosalinda
4 Replies

3. Shell Programming and Scripting

How to read a file and assign variables to data?

Hi, I need a simple csh script to read a file containing data like this Buy Transactions : 175 Sell Transactions : 212 Server: sepo2 i want to read both field and its value and assign variables to each.. (2 Replies)
Discussion started by: pravsripad
2 Replies

4. Shell Programming and Scripting

Read file and for each line replace two variables, add strings and save output in another file

Hi All, I have a file, let's call it "info.tmp" that contains data like this .. ABC123456 PCX333445 BCD789833 I need to read "info.tmp" and for each line add strings in a way that the final output is put /logs/ua/dummy.trigger 'AAA00001.FTP.XXX.BLA03A01.xxxxxx(+1)' where XXX... (5 Replies)
Discussion started by: Andy_ARG
5 Replies

5. Shell Programming and Scripting

Read record from the text file & assign those values to variables in the script

For eg: I have sample.txt file with 4 rows of record like: user1|password1 user2|password2 user3|password3 user4|password4 The username and password is sepsrated by '|' I want to get the 1st row value from the file and assign it to two different variables(username and password) in my... (1 Reply)
Discussion started by: priya001
1 Replies

6. Shell Programming and Scripting

Read file from input and redirect to output file

Hi , i am having an file which contains 5 file_name data, i need to read the file name and will perform certain operation and generate out file names with named as 5 individual file_names for eg: file.txt contains file_name1.txt|hai file_name2.txt|bye file_name3.txt|how... (3 Replies)
Discussion started by: rohit_shinez
3 Replies

7. Shell Programming and Scripting

Read record from the text file contain multiple separated values & assign those values to variables

I have a file containing multiple values, some of them are pipe separated which are to be read as separate values and some of them are single value all are these need to store in variables. I need to read this file which is an input to my script Config.txt file name, first path, second... (7 Replies)
Discussion started by: ketanraut
7 Replies

8. Shell Programming and Scripting

Do While Loop + Read From File + assign line to a variable

Hello, I am using below code for reading from a file and assigning the values to a variable , but it is loosing the value after the loop , please suggest to retain the value of the variable after the loop , while IFS=: read -r line do set $dsc=$line echo 'printing line variable ' $line... (1 Reply)
Discussion started by: ParthThakkar
1 Replies

9. Shell Programming and Scripting

ksh - Read input from file and output CSV i same row

Hello I have the following output and want the output to look: FROM: GigabitEthernet0/0 is up, line protocol is up 1 input errors, 0 CRC, 0 frame, 1 overrun, 0 ignored 275 output errors, 0 collisions, 3 interface resets GigabitEthernet0/1 is up, line protocol is up 0... (4 Replies)
Discussion started by: JayJay2018
4 Replies

10. UNIX for Beginners Questions & Answers

How To Read a File and Assign the line values to an Array?

i have this basic code that i wrote to read a file and place it's values to an array. the source/input file will have multiple strings on it that is separated by a whitespace. sample_list.txt file contents: ACCT1 TABLE1 ACCT2 TABLE2 ACCT3 TABLE3 script file: sample_list.sh ... (3 Replies)
Discussion started by: wtolentino
3 Replies
SSAAgentIsAlive(3SNMP)					      SNMP Library Functions					    SSAAgentIsAlive(3SNMP)

NAME
SSAAgentIsAlive, SSAGetTrapPort, SSARegSubtable, SSARegSubagent, SSARegSubtree, SSASendTrap, SSASubagentOpen - Sun Solstice Enterprise Agent registration and communication helper functions SYNOPSIS
cc [ flag ... ] file ... -lssagent -lssasnmp [ library .. ] #include <impl.h> extern int SSAAgentIsAlive(IPAddress *agent_addr, int *port, char *community, struct timeval *timeout); extern int SSAGetTrapPort(); extern int *SSARegSubagent(Agent* agent); int SSARegSubtable(SSA_Table *table); int SSARegSubtree(SSA_Subtree *subtree); extern void SSASendTrap(char *name); extern int SSASubagentOpen(int *num_of_retry, char *agent_name); DESCRIPTION
The SSAAgentIsAlive() function returns TRUE if the master agent is alive, otherwise returns FALSE. The agent_addr parameter is the address of the agent. Specify the security token in the community parameter. You can specify the maximum amount of time to wait for a response with the timeout parameter. The SSAGetTrapPort() function returns the port number used by the Master Agent to communicate with the subagent. The SSARegSubagent() function enables a subagent to register and unregister with a Master Agent. The agent parameter is a pointer to an Agent structure containing the following members: int timeout; /* optional */ int agent_id; /* required */ int agent_status; /* required */ char *personal_file; /* optional */ char *config_file; /* optional */ char *executable; /* optional */ char *version_string; /* optional */ char *protocol; /* optional */ int process_id; /* optional */ char *name; /* optional */ int system_up_time; /* optional */ int watch_dog_time; /* optional */ Address address; /* required */ struct _Agent; /* reserved */ struct _Subtree; /* reserved */ The agent_id member is an integer value returned by the SSASubagentOpen() function. After calling SSASubagentOpen(), you pass the agent_id in the SSARegSubagent() call to register the subagent with the Master Agent. The following values are supported for agent_status: SSA_OPER_STATUS_ACTIVE SSA_OPER_STATUS_NOT_IN_SERVICE SSA_OPER_STATUS_DESTROY You pass SSA_OPER_STATUS_DESTROY as the value in a SSARegSubagent() function call when you want to unregister the agent from the Master Agent. Address has the same structure as sockaddr_in, that is a common UNIX structure containing the following members: short sin_family; ushort_t sin_port; struct in_addr sin_addr; char sin_zero[8]; The SSARegSubtable() function registers a MIB table with the Master Agent. If this function is successful, an index number is returned, otherwise 0 is returned. The table parameter is a pointer to a SSA_Table structure containing the following members: int regTblIndex; /* index value */ int regTblAgentID; /* current agent ID */ Oid regTblOID; /* Object ID of the table */ int regTblStartColumn; /* start column index */ int regTblEndColumn; /* end column index */ int regTblStartRow; /* start row index */ int regTblEndRow; /* end row index */ int regTblStatus; /* status */ The regTblStatus can have one of the following values: SSA_OPER_STATUS_ACTIVE SSA_OPER_STATUS_NOT_IN_SERVICE The SSARegSubtree() function registers a MIB subtree with the master agent. If successful this function returns an index number, otherwise 0 is returned. The subtree parameter is a pointer to a SSA_Subtree structure containing the following members: int regTreeIndex; /* index value */ int regTreeAgentID; /* current agent ID */ Oid name; /* Object ID to register */ int regtreeStatus; /* status */ The regtreeStatus can have one of the following values: SSA_OPER_STATUS_ACTIVE SSA_OPER_STATUS_NOT_IN_SERVICE The SSASendTrap() function instructs the Master Agent to send a trap notification, based on the keyword passed with name. When your sub- agent MIB is compiled by mibcodegen, it creates a lookup table of the trap notifications defined in the MIB. By passing the name of the trap notification type as name, the subagent instructs the Master Agent to construct the type of trap defined in the MIB. The SSASubagentOpen() function initializes communication between the subagent and the Master Agent. You must call this function before calling SSARegSubagent() to register the subagent with the Master Agent. The SSASubagentOpen() function returns a unique agent ID that is passed in the SSARegSubagent() call to register the subagent. If 0 is returned as the agent ID, the attempt to initialize communication with the Master Agent was unsuccessful. Since UDP is used to initialize communication with the Master Agent, you may want to set the value of num_of_retry to make multiple attempts. The value for agent_name must be unique within the domain for which the Master Agent is responsible. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5) SunOS 5.10 17 Dec 1996 SSAAgentIsAlive(3SNMP)
All times are GMT -4. The time now is 02:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy