PDA

View Full Version : Nerd Alert! Unix shell programmers...



Veritas
5/12/2006, 10:25 AM
...if you know of any good online resources for a complete n00b at this, can you PM me? I know C++ on the win32 side, but haven't done any shell programming.

TIA.

Veritas
5/12/2006, 10:26 AM
I'll just save some time here...

<snarky colley comment>

yermom
5/12/2006, 10:26 AM
what are we talking about here?

what are you trying to do?

what are you using? bash?

yermom
5/12/2006, 10:27 AM
<insert snarky comment here>

Osce0la
5/12/2006, 10:28 AM
I thought this thread was about 1TC and his tricycle :mad:

yermom
5/12/2006, 10:29 AM
if he was a shell programmer i don't think he'd be asking about his USB ports ;)

Norm In Norman
5/12/2006, 10:30 AM
I've done some bash stuff fairly recently and it sucks. Generally, answers to questions are "RTFM." I think this guide seems familiar:

http://www.tldp.org/LDP/abs/html/

I frickin hate it. One time i spent like 4 hours on a problem, and the whole thing revolved around an extra space in the wrong spot.

Veritas
5/12/2006, 10:35 AM
what are we talking about here?
I dunno. That's the issue.


what are you trying to do?
I've got a cronjob pulling down an XML file every five minutes or so. What I need to do is take that XML file, parse it, and insert certain values into a MySQL database.

The difficulty is that the XML file is damn large, and using a PHP script is horridly inefficient. I don't know Perl very well at all. But I know C, so...


what are you using? bash?
Yeah. Although I know there are shells that may be more conducive to programming.

Given that info if you guys have a better idea I'm all ears.

yermom
5/12/2006, 10:40 AM
sounds like you should be using Perl for that...

there are modules to talk directly to MySQL or Oracle or whatever

not that i ever use them... but i've had to install them for people

colleyvillesooner
5/12/2006, 10:42 AM
I'll just save some time here...

<snarky colley comment>

HEY! :mad:

I resent that......

























http://www.horrordvds.com/reviews/misc/pictures/nerds.jpg

Veritas
5/12/2006, 10:44 AM
sounds like you should be using Perl for that...

there are modules to talk directly to MySQL or Oracle or whatever
Sighs.

I know. I got a book on Perl at the library yesterday. I just don't want to have to deal with learning new syntax and new weird little rules. Usually I'm all about learning something new, but I've got so much **** to do right now that I just want this done and off my plate.

So. Perl. Are there any decent IDEs or do I get to spend some happy time in vi?

yermom
5/12/2006, 10:47 AM
i basically use vi for everything... but i'm not really much of a programmer

sooner n houston
5/12/2006, 10:47 AM
Get "Unix in a nutshell", "sed and awk", and "learning the Korn shell", all by O'Rielly and Assoc. Or if your near Bentonville, I could loan them to you! :D

sooner n houston
5/12/2006, 10:49 AM
Are there any decent IDEs or do I get to spend some happy time in vi?


Oh man I love me some vi!!! :D

Veritas
5/12/2006, 10:49 AM
Does "Learning the Korn Shell" have the bass tab for Freak on a Leash? I'm stuck on the bridge. ;)

I'm not "close" to Bentonvile, per se.

colleyvillesooner
5/12/2006, 10:51 AM
Does "Learning the Korn Shell" have the bass tab for Freak on a Leash? I'm stuck on the bridge. ;)


Swing and a miss.

Don't worry, you'll be back to old form soon. :D

Vaevictis
5/12/2006, 11:23 AM
As a general rule, the stuff you want to use shell programming for, you are probably going to pick up naturally in your day to day use of the shell interactively, with a smattering of man page.

For all other scripting, you probably want perl or python. -- Perl if you want quick dirty and powerful, and python if you want something a little more organized.

emacs and vi are the generally recommended IDEs for perl. And in case you think I'm joking: I'm not.

SoonerInKCMO
5/12/2006, 11:25 AM
Sighs.

I know. I got a book on Perl at the library yesterday. I just don't want to have to deal with learning new syntax and new weird little rules. Usually I'm all about learning something new, but I've got so much **** to do right now that I just want this done and off my plate.

So. Perl. Are there any decent IDEs or do I get to spend some happy time in vi?

I may have some Perl code laying around that parses text files and sticks the data in a database. Oracle though... but that just means you'd need to load a different module than what I'm using.

Lemme look around...

LSUdeek
5/12/2006, 11:44 AM
i generally recommend python for doing what you are trying to do. hell, for parsing xml files? throw up something in c#/mono. you can cron anything sir.

SoonerInKCMO
5/12/2006, 11:44 AM
Hmmm.... looks like all my stuff is for comma-delimited files... since the parsing is probably the most complicated part, it probably won't do you any good to see my code. Sorry.

Sooner_75
5/12/2006, 11:50 AM
http://www.ss64.com/bash/

http://linux-newbie.sunsite.dk/index.html

Norm In Norman
5/12/2006, 12:31 PM
There is a mysql command that imports a file into a table, but I think it has to be a csv file or something. Something that took php like 3 minutes to import it imported in less than a second. The problem is you need something to go from xml to the csv file. or is it tab seperated...

slickdawg
5/12/2006, 12:33 PM
Man, little did I know that I had fellow unix geeks on sf.com


VI ROOOLZ!@@$@#$

Norm In Norman
5/12/2006, 12:43 PM
http://dev.mysql.com/doc/refman/5.0/en/mysqlimport.html

I dunno if that command will help you or not. You'd have to parse your XML file and create an import file first. I wouldn't be too surprised if there isn't something already out there that does that part for you too. mysqlimport is really damned fast, btw.

Vaevictis
5/12/2006, 03:29 PM
Man, little did I know that I had fellow unix geeks on sf.com


VI ROOOLZ!@@$@#$

We are everywhere, waiting in the shadows for the right time to rise up in revolt against the Redmondian Overlords to restore us to our rightful place on all low end to mid-range computers everywhere.

Stoop Dawg
5/12/2006, 03:39 PM
If you know C, why not just write a C app?

If it where me, I'd write a Win32 app to do the work. I'd pull the file off the *nix box with FTP or SAMBA.

Hell, I'd nix the cron job altogether and do it all from Win32. Actually, from .NET.

I'm pretty sure this isn't the advice you're looking for, so I'll stop.

Stoop Dawg
5/12/2006, 03:40 PM
We are everywhere, waiting in the shadows for the right time to rise up in revolt against the Redmondian Overlords to restore us to our rightful place on all low end to mid-range computers everywhere.

If you're seriously still coding in vi, I'm not worried. ;)

yermom
5/12/2006, 03:47 PM
If you're seriously still coding in vi, I'm not worried. ;)

if you're still using Windows, we aren't either ;)

Getem
5/12/2006, 05:31 PM
Yeah, i'd do it in C, since you already know C. The mysql C lib is plenty high level, and I don't know that the shell would be that much faster than PHP, would it? Still interpreted.

Although, depending on what you are doing, it might just be a few grep commands and the mysql import that Norm mentioned.

StoopTroup
5/12/2006, 05:36 PM
...if you know of any good online resources for a complete n00b at this, can you PM me? I know C++ on the win32 side, but haven't done any shell programming.

TIA.
Sure...

We ask where you've been lately and all we get is...

"I need help."

Vaevictis
5/13/2006, 12:49 AM
If you're seriously still coding in vi, I'm not worried. ;)

Noway, I'm a pico ninja, man! ;p