Thoughts: how to design utility similar to the unix/linux
I want to take the "ls -la" output, in order to create binary tree nodes, which will contain the name of the file, its location, its size, and the permission.
I did "ls -la > tmp" and i am trying to use the output of the tmp file. Here's a snapshot:
-rw-r--r-- 1 root root 160920 Jun 11 21:10 BOOKOSI.TTF
-rw-r--r-- 1 root root 160940 Jun 11 21:10 BOOKOS.TTF
-rw-r--r-- 1 root root 7216 Jun 11 21:10 cga40737.fon
-rw-r--r-- 1 root root 6352 Jun 11 21:10 cga40850.fon
-rw-r--r-- 1 root root 6672 Jun 11 21:10 cga40852.fonAs you can see there are 9 collumns, which are THEORETICALLY separated with spaces(or tabs) and there is also a EOL at the end. Unfortunately both assumptions are wrong.
Hers's a part of the program, i have written:
private static void analyzeInputCreateNodes() throws IOException
File f= new File("/home/kostas/tmp3");
FileInputStream fin= new FileInputStream(f);
DataInputStream in= new DataInputStream(fin);
StreamTokenizer tokenizer=new StreamTokenizer(in);
tokenizer.resetSyntax();
//tokenizer.wordChars(0,100);
String s="";
String s2="";
String[] entryTable= new String[10];
// String[] entryTable={"0","0","0","0","0","0","0","0","0","0"};
StringBuffer sb= new StringBuffer();
int lineCounter=0;
int entryCounter=0;
while(tokenizer.nextToken()!= StreamTokenizer.TT_EOF)
s=(new Character((char)tokenizer.ttype)).toString();
if (tokenizer.ttype==StreamTokenizer.TT_EOL)
for (int i=0; i<=9; i++)
System.out.print(entryTable[i]+" ");
//System.out.println();
entryCounter=-1;
entryTable[++entryCounter]=new Integer(lineCounter++).toString();
if (!(s.equals(" ")))
s2=sb.append(s).toString();
else
if (s.equals(" "))
entryTable[++entryCounter]=s2;
lineCounter++;
}And here's what i found out when i changed the code and added the following part:
if (tokenizer.ttype==StreamTokenizer.TT_EOL)
System.out.println("EOL");
s=(new Character((char)tokenizer.ttype)).toString();
if (s.equals(" ")) System.out.println("space");This output proved my assumptions wrong:
space
space
space
space
space
space
space
space
EOL
space
space
space
space
space
space
space
space
EOL
space
space
space
space
space
space
space
space
EOL
space
......Do you have any ideas about how i can improve this?
Is there a way to create string patterns? (I don't know if it's called that way).
Post some keywords, links about it.
Thanks
Not clear what the problem is, that is, what you feel the problem is. Is it that you're getting one whitespace character between tokens on the input lines? Are you sure that this isn't an artifact of StreamTokenizer? (maybe it's collapsing whitespace?)
The problem with parsing the output of "ls -la" is that its output can be more complex than you may be anticipating. For example, I believe the date format will change if the file is sufficiently old. This is going to be system-dependent, of course, and thus not so portable. This is the kind of problem that explodes in complexity when you least expect it.
Is there any particular reason that you're not just using java.io.File?
Similar Messages
-
Do I need and how to secure the Unix/Linux agents authentication and communication to RMS?
Hi everybody
We have an environment including SCOM 2012 SP1, 10 windows server, 40 linux servers and 10 HP-UX servers. all of them are joined a trusted domain. I know the authentication method between windows agents and management server is kerberos. but not for linux and
HP-UX servers.
Now I want to secure the Unix/Linux agents authentication and communication to RMS. some questions:
1- how much secure and credible is current authentication method? and in a high secure environment can I trust SCOM self signed Certificates?
2- Considering this point that Unix/linux computers are joined to active directory domain and are using Kerberos to authenticate, can I use this
authentication method between RMS and linux Agents?
3- if I make a decision to use certificates should I use gateway server? (considering all servers and RMS are in same trusted domain)
any other suggestion?
Thanks in advancenothing?
-
How to start a particular database in unix/linux
Hi,
Could any one tell me how to start a particular database in Unix/Linux assuming that my server consists of 10 databases.
Can we use LSNRCTL tool for this??
Regards,
Nagarjun.> Could any one tell me how to start a particular database in Unix/Linux
assuming that my server consists of 10 databases.
There is something very wrong in basic understanding of Oracle RDBMS architecture, when running 10 Oracle instances on a single server.
10x temp space. 10x redo space. 10x SGA. 10x system processes footprint. This is NOT how one scales Oracle and NOT how one uses Oracle optimally. -
SCOM 2012 R2 UR4 upgrade question - where exactly is the UNIX/Linux agent?
I am practicing the UR4 on a test |SCOM environment (my first upgrade) and our UNIX Admins have requested the "UNIX/Linux agent" so they can create packages to upgrade the UNIX/Linux agents when the time comes.
I have downloaded all the UR4 updates/software. Where exactly is the agent for UNIX/Linux machines?
I opened the "Update Rollup 4 for Microsoft System Center 2012 R2 - Operations Manager Agent (KB2992020)" folder and I saw the following agents:
amd64-agent.msp
i386-agent.msp
Are one of these the UNIX/Linux agents?
I know I'm overlooking something here since this is my first time. Any assistance is greatly appreciated.
ThanksHello,
After deploy UR4: http://support.microsoft.com/kb/2992020
Installation instructions for Operations Manager - UNIX and Linux Monitoring (Management Pack Update)
To install the updated monitoring packs and agents for UNIX and Linux operating systems, follow these steps:
Apply Update Rollup 4 to your System Center 2012 R2 Operations Manager environment.
Download the
updated management packs
(http://www.microsoft.com/downloads/details.aspx?FamilyID=9f947878-6bf6-48a1-adb1-3cc4c2e5d4af)
for System Center 2012 R2.
Install the management pack update package to extract the management pack files.
Import the updated management pack for each version of Linux or UNIX that you are monitoring in your environment.
Upgrade each agent to the latest version by using either the Update-SCXAgent Windows PowerShell cmdlet or the UNIX/Linux Agent Upgrade Wizard in the Administration pane of the Operations Console.
Regards,
Regards, Mazen Ahmed -
How to insert special characters in the Unix FrameMaker?
Dear All,
I want to insert the abbreviation of millisecond (which is quite similar to "us") and ≤ in the Unix FrameMaker.
Any hints?
Thanks.Hi, Alice:
Look in the OnlineManuals directory in the FM installation directory for CharacterSets.pdf There's a table of all characters in fonts (pre-OpenType) and the equivalent keystrokes or codes they need. Also look for MultiplePlatforms.pdf which has platform-specific notes.
HTH
Regards,
Peter Gold
KnowHow ProServices -
Cfdocument: How to design a PDF excactly the way I want?
Hello everybody
I’m trying to produce PDF files with cfdocument for a
Clinique here in Switzerland. I’m using the developer version
of CF8. A big issue is that I am supposed to make the PDF look like
it would have been printed on a prefabed letter, means that the
header and the footer both containing images on the right position
in the right dimensions. Furthermore the margins for the content
should have defined values:
Top: 5,5 cm
Left: 3,7 cm
Right: 2,8 cm
Bottom: 3,0 cm
I wasn’t able so far to create this because I
don’t have any control of the layout of the headers and
footer, means no control about sizing the images or sizing the
header/footersections or placing the images precisely in these
sections!
I don’t know whether my basic idea using header and
footers is right, may be there is a way to print text in a existing
blank PDF which already contains what I described as header and
footer? Would be great!
I put all elements I’m using on the following link
http://augenklinik.be/cfdocument.zip.
It contains:
default.cfm: contains the code
IS.pdf: what cfdocument generates for the moment (it's far to
big in filesize!!)
SHOULD_BE.pdf: what I would like cfdocument to produce!
BE_HEADER.png: header image (much bigger but shows perfect in
PDF after scaling down)
BE_FOOTER.png: header image (much bigger but shows perfect in
PDF after scaling down)
The best would be if anybody could write me a sample code for
the above described problem – would be great!
Thank you very much for your helpHi Sanjeev,
I have currently the same issue, please have you solved it?
Thank you
Tomas -
Is there any command in windows batch file similar to the unix grep command
Hi,
I have a batch file which will return status of the Database to a file ex: "OPEN". Now I want to read this output file and check for the "OPEN" string from another batch file. any suggestions?. This is similar to "grep" command in unix. I want this to be done in windows batch file.
This is my actual batch file
rem -- Description: Check whether the Database is UP
rem -- Usage:
rem -- ORACLE_SID is input parameter for the file
rem --
rem --start of batch file
@echo off
set ORACLE_SID=%1
echo connect plp/ltd1plp@%1
echo set cmdsep on
echo set cmdsep '"'; --"
echo set term on
echo spool c:/status_log.log
echo select status from v$instance;
echo spool off
) | sqlplus /nolog
rem --end batch file
Thanks.The same link from [google cache|http://209.85.229.132/search?q=cache:EJrm9tgj0a8J:www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/find.mspx+windows+find&cd=1&hl=en&ct=clnk&client=opera]. Also you can use help:
find /? -
How to use different jdk on windows/unix/linux OS?
Hi,
I always use differen jdk/jre version. but always I delete first then I install jdk/jre which version I want. My question is how I change system jdk/jre setting don't uninstall jdk?If you have multiple monitors and run Linux, you may want to display different images as your wallpaper on each monitor. There's a utility for that – Nitrogen. The blackMORE Ops blog has a nice how-to on getting Nitrogen and configuring it, with step-by-step instructions and plenty of screenshots.
This topic first appeared in the Spiceworks Community -
Hi There,
I'm trying to set up the nodemanager service in *nix (RHEL 5.3) env. My goal is, when a server reboots and it comes up, I want to get the nodemanager startsup by itself and start the admin server and managed server.
Any answers/suggestions are much appreciated.
Thanks
GMThis one is from Solaris. The only thing you would have to change is the ps command. Just find the right ps command that works for you.
#!/bin/sh
# Name: S98nodemanager11g
# Description: File to start Weblogic Nodemanager at system boot time
NODEBIN=/opt/bea/nodemanager11g
NODELOGDIR=${NODEBIN}/logs
NODELOGFILE=${NODELOGDIR}/startup.log
case "$1" in
'start')
nm=`/usr/ucb/ps -auxwwww |egrep '^root.*jdk6.*weblogic.NodeManager' |grep -v grep | awk '{print $2}'`
if [ -n "$nm" ] ;then
echo "Nodemanager for Weblogic 11g is already running. pid=$nm"
else
echo "Starting Nodemanager for Weblogic11g"
mv $NODELOGFILE $NODELOGFILE.old
cd $NODEBIN;./startNodeManager.sh > $NODELOGFILE 2>&1
fi
'stop')
nm=`/usr/ucb/ps -auxwwww |egrep '^root.*jdk6.*weblogic.NodeManager' |grep -v grep | awk '{print $2}'`
if [ -n "$nm" ] ;then
echo "Forcing shutdown of Nodemanager for Weblogic11g."
kill $nm
else
echo "Nodemanager for Weblogic 11g is not running."
fi
echo "Usage: $0 { start | stop }"
exit 1
esac
exit 0 -
Design multiple elements in the same row
hi,
i am new to web dynpro java. how to design multiple elements in the same row. ie a textfield and inputfield in the same row in form design layout.
thanxHi Viral Patel,
To design multiple elements in the same row. Follow below Steps
1.) Open your View --> Select Layout Tab --> In the Outline Explorer --> There will be a Default " RootUIElementContainer " --> Select it --> Right Click & Select Insert Child Option --> A new Window appears --> Select TransparenContainer & Press Finish --> Now Select TransparentContainer --> Right Click & Select Insert Child Option --> Add TextView and Press Finish --> Similarly add InputField to the newly added TransparentContainer.
---> Now to add above two UI Elements in the same row in form design layout --> Select Newly added TransparentContainer --> In the Properties Change layout Property to GridLayout & set colCount --> 2 .
It will make the above two UI Elements in the same Row
With Regards,
Roop Kumar. -
Hi gurus,
How to design ODS, what are the guidelines for designing it. Is there any difference between Infocube design and ODS design. please send to : [email protected]
thanks and regards
bhaskarHi,
http://help.sap.com/saphelp_sem40bw/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm
Check your mail box.
Assign points if helpful. -
Hello all, now that I know the hardware aspects of the mac I thought it's about time I learned the Unix system. I really only know DOS commands, windows, and anything else dealing with the Windows system. I'm ashamed to say I can't even figure out how to use a .tar.gz file even though I researched it too.. I don't truly want to waste anyone's time but if you would it is greatly appreciated.
Hi 21q,
I was just passing by. Would you like some names of classical introductory books (primers) that present +unix wizards+ used when they were in your place? They're likely unwanted today, so sell for pennies on places like
http://www.bookfinder.com/
+Panther's Darwin+ used Linux, and Tiger's used +BSD Unix+ (the Berkeley Service Distribution), +AT&T's System V+ with many networking additions to help academics & students communicate. Unix was an elegant 'system'. The beautiful book by Steven Bourne, however, you'll find useless without its commands, at least, re-installed to Darwin.
Some Berkeley extensions, such as finger, were removed when the internet went public. You can still use these on your LAN, though! One day I was using spell and its list in text of all words in +Webster's 2d International Dictionary+ to create limited vocabularies for my 5-year old granddaughter The next day the list was gone. So, ask these knowledgeable people where to get these commands. (Archives other than Fink require you know unix already to get it.) It's free, and the source code is included!
It is very helpful to know what the 2- or 3-letter commands mean, because there are hundreds (as opposed to a dozen on DOS). Though I thought they were designed short & in lower case so several could be on one line, Ken Thompson said he was just a poor touch typist.
The low-level unix 'commands', designed to be incorporated into C programs, are still here, so you can write C-language applications using these. Again, we can refer you to the best introductions.
Note that 'tar' stood for 'tape archiver', which concatenated & copied many files as one, and 'gz' likely stood for the compression utility 'GNU zip' (as it zipping your suitcase). No list of 'official meanings' exists, so guessing their meaning is an ongoing puzzle. 'Biff', however, you'll never guess: this command, which beeped when mail arrived, was the name of its author's dog, who barked instead. The pair, '.tar.gz' is often referred to as a 'tar ball'.
I shan't discuss why Unix, originally built for use by two people on one small machine, spread like fire throughout universities, but the original unix was a work of art. You can appreciate this if you can get most of it back, though you can no longer use such scripts as 'rc' (run command?) in /etc to configure your system.
With primers on programming, books by Comer or Tannenbaum, and the source code on archives, you can use your Mac to master programming to any level. Though Objective-C, I'm told, is elegant, and AppleScript powerful; these are not ISO standard languages, portable to any computer. So I'd recommend learning Unix & C early, using either the vi or emacs editor.
This is a slight expansion of Neil's reply.
Bruce
PS. Unix has three 'standard' devices to work with: standard input, standard output, and standard error. These were originally displayed on separate monitors, but standard input is now your keyboard & mouse, standard output the 'Terminal', and standard error is the 'Console' (named after a network administrator's console). I direct all errors to the console, and placed it in my dock. -
We have upgraded our System Center to 2012 R2, and we cannot open any of the UNIX/Linux LogFile monitor property or the UNIX/Linux process monitor property for those monitors created prior to the upgrade. Error we get is below. Any assitance
appreciated.
Date: 9/30/2014 10:01:46 PM
Application: Operations Manager
Application Version: 7.1.10226.0
Severity: Error
Message:
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection,
Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection,
Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection,
Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at Microsoft.EnterpriseManagement.Internal.UI.Authoring.Extensibility.TypeContainer.get_ContainedType()
at Microsoft.EnterpriseManagement.Internal.UI.Authoring.Extensibility.MomExtensionsCommon.AddTemplatePages(LaunchTemplateUIData launchData, Form form)
at Microsoft.EnterpriseManagement.Internal.UI.Authoring.Extensibility.MomExtensionsCommon.Initialize(Object launchData, Form form)
at Microsoft.EnterpriseManagement.Internal.UI.Authoring.Extensibility.MomExtensionsCommon.RunPrivate(Object[] userData)
at Microsoft.EnterpriseManagement.Internal.UI.Authoring.Extensibility.MomExtensionsCommon.Run(Object[] userData)It's possible the upgrade did not update everything properly as it looks like a dll mismatch or a missing file. I'd open a support ticket with MS and have a support engineer look at the upgrade logs. What version of SCOM did you upgrade from?
Regards,
-Steve -
Looking To Delete|Hide The "Monitoring\UNIX/Linux Computers" State View
Seeing as we do not manage any UNIX/Linux boxes in our environment, I’d like to be able to remove the
UNIX/Linux Computers state view from the console.
I was able to track the view down to Microsoft.Unix.Servers.State.View, hosted by the
Microsoft.Unix.Views MP, which is unfortunately sealed.
This of course is preventing me from simply deleting the view directly from the console.
Also, it would appear that the Show or Hide Views… option should instead be labeled
Show or Hide Folders..., as it only allows for showing/hiding folders!!!
Can anyone suggest an alternative?
Thanks,
LarryHi,
If you don't have any Unix/Linux boxes you could delete the Unix/Linux management pack. After deleting, you will not have Unix/Linux Computers state view
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. -
How to design the URL?i know that the Google will take down the good URL.such as the staticize URL Google will like more..
A site's URL structure should be as simple as possible. Consider organizing your content so that URLs are constructed logically and in a manner that is most intelligible to humans (when possible, readable words rather than long ID numbers). For example, if you're searching for information about aviation, a URL like http://en.wikipedia.org/wiki/Aviation will help you decide whether to click that link. A URL like http://www.example.com/index.php?id_sezione=360&sid=3a5ebc944f41daa6f849f730f1, is much less appealing to users.
Consider using punctuation in your URLs. The URL http://www.example.com/green-dress.html is much more useful to us than http://www.example.com/greendress.html. Google recommends that you use hyphens (-) instead of underscores (_) in your URLs.
Overly complex URLs, especially those containing multiple parameters, can cause a problems for crawlers by creating unnecessarily high numbers of URLs that point to identical or similar content on your site. As a result, Googlebot may consume much more bandwidth than necessary, or may be unable to completely index all the content on your site.
Maybe you are looking for
-
Ipad won't sync all of photo library.
I have recently bought an iPad 2. I updated it to ios5 and it does not sync my complete iPhoto library. I have ~9000 photos in my library, only about 3000 of which are being transferred to my iPad. There is plenty of space on the iPad 32GB of a 64GB
-
Want To Capture The File name Using the SQL Loader
Hi, I Am loading The Data To Staging Table Using The SQL*developer, The File That need to be Loaded Will be One Of The Input To the SQL*Loader Concurrent Program. In One Of The Column Of My staging Table I want To Put The File name. Can We do the Sam
-
Hello friends! I need an app to take picture automatically in specified interval... any ideas? Solved! Go to Solution.
-
Cannot re-install Adobe reader. Says "Adobe reader wants to make changes" and gives my name not e-mail address then asks for a PW. I received a new PW and can sign into Adobe.com but am unable to install Adobe reader on my MAC.
-
Error installing Images for 3.2 into XE
I am receiving the following error messages when I am upgrading APEX 2... to Apex 3.2 in Oracle XE. The basic upgrade completed...and I changed the admin password. When I attempt to load the images...this is what happens: @apxldimg.sql C:\temp PL/SQL