Sponsored Content
Top Forums Shell Programming and Scripting String parsing help across multiple UNIX platforms Post 302998939 by harleyvrodred on Friday 9th of June 2017 10:18:27 PM
Old 06-09-2017
Nice examples. I took this and made a command I could put into the clipboard and paste into a telnet window. Because I want to select-cut the result into the clipboard I'm wrapping the output onto as few lines as possible.

Code:
sh << 'PASTE'
xml_token () {
 variable=$(awk -F'"' -v pattern="$1" '
   $2 == pattern {
    split($4, t, / /)
    getline
    split($0, m, /[<>]/)
    o = sprintf("{%s %.1f %s}", FS pattern FS, t[1] * m[3], t[2])
   }
  END {	print o
   }' $2)
 if [ $(( ${#buff} + ${#variable} )) -ge $twidth ]; then
  echo $buff; buff=$variable
   else
  buff+=$variable
   fi
}
twidth=`tput cols`
xml_token 'Coolant Temp' ~me/cooling.xml
xml_token 'Cabinet Temp' ~me/cooling.xml
echo $buff
'PASTE'

The Output using the example file is:
Code:
{"Coolant Temp" 30.7 C}{"Cabinet Temp" 36.0 C}

I was thinking about the possibility of making the search pattern string contain a list, as in:
Code:
xml_token '/Coolant Temp/ || /Cabinet Temp/' ~me/cooling.xml

I could make the list of search patterns as many as I needed, certainly more than 2. More like a dozen or so search strings (or patterns as they are here). My attempts have failed, ideas?

Last edited by harleyvrodred; 06-10-2017 at 11:18 AM.. Reason: add output script produces
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Patch Management over mixed unix platforms

Does anyone know of any tools that manage the rollout of patches across multiple types of Unix platform ( eg Solaris, Aix etc ). I am looking for something that does a similiar job to SMS or WSUS in the Windows world (3 Replies)
Discussion started by: jimthompson
3 Replies

2. Shell Programming and Scripting

Parsing of file for Report Generation (String parsing and splitting)

Hey guys, I have this file generated by me... i want to create some HTML output from it. The problem is that i am really confused about how do I go about reading the file. The file is in the following format: TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
Discussion started by: umar.shaikh
8 Replies

3. UNIX for Dummies Questions & Answers

Unix Platforms

Hi. Where can i learn, Which Unix platform specific for what? Properties? (1 Reply)
Discussion started by: Enrgy
1 Replies

4. UNIX and Linux Applications

Platforms using Unix

Hi ;) Which hardware platforms/machine types use the Operating System Unix? A list of all would be appreaciated Thx Megadrink :cool: (2 Replies)
Discussion started by: Megadrink
2 Replies

5. Shell Programming and Scripting

Logfile parsing with variable, multiple criterias among multiple lines

Hi all I've been working on a bash script parsing through debug/trace files and extracting all lines that relate to some search string. So far, it works pretty well. However, I am challenged by one requirement that is still open. What I want to do: 1) parse through a file and identify all... (3 Replies)
Discussion started by: reminder
3 Replies

6. Programming

How do I find the MAC address in C on different UNIX platforms?

I need to find the MAC address of the ethernet cards on the host machine from the C language. I have found a way to do this on Linux using socket(), ioctl() and the ifreq structure. But this does not seem to work on AIX, HP/UX and probably the others I need (Solaris, SCO, Alpha etc). Is there a... (7 Replies)
Discussion started by: Pug
7 Replies

7. Shell Programming and Scripting

string parsing using UNIX

I got multple sql files.such as >>vi abc.sql select A.SITENAME, NULL NULL A.CREATE_DTM NULL A.MODIFY_DTM NULL FROM ${STG_RET_ITEM} A INNER JOIN ${STG_INC_COMP} B ON (A.CUSTID=B.CUSTID) LEFT OUTER JOIN ( select C.SITEID,SITESTATUS,MIN_EFF_DT,CURR_ST_DT,MAX_IN_DT,MAX_ACT_DT from... (4 Replies)
Discussion started by: ali123
4 Replies

8. Shell Programming and Scripting

Multichecks across all unix platforms

Can somebody refer me following multicheck to perform across most of unix platform like AIX, HP-UX, solaris, Linux. CPU utilization above X% Check IO above X% Swap usage check above X% Memory utilization above X% ... (3 Replies)
Discussion started by: sendtoshailesh
3 Replies

9. Shell Programming and Scripting

Specific string parsing in Linux/UNIX

Hi, I have a string which can be completely unstructred. I am looking to parse out values within that String. Here is an example <Random Strings> String1=<some number a> String2=<some number b> String3=<some number c> Satish=<some number d> String4=<some number e> I only want to parse out... (1 Reply)
Discussion started by: satishrao
1 Replies

10. Shell Programming and Scripting

Parsing OSX UNIX command results which print in multiple lines

from the CLI on a Mac, if you type networksetup -listallnetworkservices then you get results in a multi-line paragraph that look something like this: networksetup -listallnetworkservices An asterisk (*) denotes that a network service is disabled. Wi-Fi Display Ethernet Bluetooth DUN... (7 Replies)
Discussion started by: hungryd
7 Replies
DwtStartCopyFromClipboard(3Dwt) 										   DwtStartCopyFromClipboard(3Dwt)

Name
       DwtStartCopyFromClipboard - Indicates that the application is ready to start copying data from the clipboard and locks the clipboard.

Syntax
       int DwtStartCopyFromClipboard(display, window, time)
	    Display *display;
	    Window window;
	    Time time;

Arguments
       display	 Specifies  a pointer to the Display structure that was returned in a previous call to XOpenDisplay.  For information on XOpenDis-
		 play and the Display structure, see the Guide to the Xlib Library: C Language Binding.

       window	 Specifies the window ID that relates the application window to the clipboard.	The same application instance should pass the same
		 window ID to each clipboard function that it calls.

       time	 Specifies the timestamping of the event that triggered the copy.

Description
       The  DwtStartCopyFromClipboard  function  notifies the cut and paste functions that the application is ready to start copying data from the
       clipboard.  DwtStartCopyFromClipboard locks the clipboard and remains locked until you call DwtEndCopyFromClipboard.

       After calling DwtStartCopyFromClipboard, an application can make multiple calls to DwtCopyFromClipboard requesting data in one  or  several
       formats.  You specify the format by setting the format_name argument to DwtCopyFromClipboard.  Each call to DwtCopyFromClipboard in a spec-
       ified format results in data being incrementally copied from the clipboard until all data with the specified format has been copied.   When
       all  data  in a specified format has been successfully copied, DwtCopyFromClipboard returns ClipboardSuccess.  When more data remains to be
       copied in the specified format, DwtCopyFromClipboard returns ClipboardTruncate.	An application can copy data in as many formats as desired
       before calling DwtEndCopyFromClipboard.

       It  is  recommended  that any calls to inquire routines needed by the application be made between the call to DwtStartCopyFromClipboard and
       the call to DwtEndCopyFromClipboard.  That way, the application does not need to call DwtClipboardLock and DwtClipboardUnlock.

       To perform cut and paste operations between your application and an application using the ICCCM clipboard selection mechanism, you must use
       DwtStartCopyToClipboard	and  provide  a  timestamping  value for time, not a CurrentTime value.  Use of the value CurrentTime for time may
       cause the ICCCM interface to fail.

       Applications do not need to use DwtStartCopyFromClipboard and DwtEndCopyFromClipboard, in which case DwtCopyFromClipboard  works  as  docu-
       mented.	However, using these two functions allows incremental copying from the clipboard and ensures ICCCM compatibility.

Return Values
       This function returns one of these status return constants:

       ClipboardSuccess   The  function is success-
			  ful.
       ClipboardLocked	  The	 function    failed
			  because the clipboard was
			  locked by another  appli-
			  cation.   The application
			  can continue to call	the
			  function  with  the  same
			  parameters   until	the
			  clipboard   is  unlocked.
			  Optionally, the  applica-
			  tion	can ask if the user
			  wants to keep  trying  or
			  to  give up on the opera-
			  tion.

See Also
       DwtCopyFromClipboard(3Dwt), DwtEndCopyFromClipboard(3Dwt)
       Guide to the XUI Toolkit: C Language Binding
       Guide to the XUI Toolkit Intrinsics: C Language Binding

														   DwtStartCopyFromClipboard(3Dwt)
All times are GMT -4. The time now is 05:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy