Shell Script Question
Matthew Carpenter
matt
Fri Jun 10 07:05:32 PDT 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Brad De Vries wrote:
> On 6/1/05, David Bandel <david.bandel at gmail.com> wrote:
>
>> Wonder why this reply didn't go to the list?
>>
>> On 6/1/05, Alma J Wetzker <almaw at ieee.org> wrote:
>>
>>> I don't do much scripting beyond expect, can you have more than
>>> one return value to a script? I counted three desired
>>> variables. Is there a way to get all three out without going
>>> to global?
>>>
>>> In C, I would pass two by reference and return the third. Can
>>> you do weird stuff like that in a script?
>>
>> Good question. And the answer is: I don't have a clue. And it
>> could be different between ksh, bash, bash2, and bash3. As soon
>> as something really needs more than very simple scripting, I drop
>> into Perl mode. In Perl I can pass several variables to a
>> subroutine, no reference needed (although Perl can do all those
>> memory tricks of passing a memory address of a variable). And
>> there are ways to get them back out, too.
>>
>> Brad, what shell are you calling and have you tried calling a
>> different one? Last time I worked on AIX and HP-UX, they didn't
>> have bash. They had borne and korn shells and that was about it
>> (unless you liked to abuse yourself with a C-shell -- which
>> should only be sold down by the sea shore).
>>
>> Ciao,
>>
>> David A. Bandel
>
>
> I use the bourne shell (#!/bin/sh) for virtually all my scripts
> because I deal with several UNIX variants (including cygwin and MKS
> Toolkit, UNIX environments on Windows.) I would love to use perl
> for many of my projects but I can't always guarantee that it will
> be installed and trying to get a sys-admin to install perl when
> they've gone without it for 10+ years is a little like trying to
> push a rope. Sadly I don't push too hard because I know shell
> scripting but my perl skills are pretty weak.
>
> I would guess that 90-95% of all my scripts work perfectly
> everywhere I go with the one big exception of this looping issue.
> Stuff I wrote in the late 80's worked this way and when I started
> working with Linux and bash I found it worked differently. Now I
> know why.
>
> To answer Alma's question about passing variables by reference, I'd
> have to say that the shell does not have that ability. Actually,
> until I started working with AIX and ksh, I'd never even heard of
> that concept of local variables in shell scripts. Ksh and bash,
> there may be others, allow the you to define local variables but in
> sh and csh every variable that you create is global.
You would probably like the book I'm reading. I know I do. It's
called "Hacking: The Art of Exploitation".
It is not just a book about hacking, it's a book teaching the real
thing. Hacking buffer overflows, format string exceptions, etc...
But it's not just a book teaching how to write exploit code. Oh no.
It teached how to exploit code from the command line using Perl and
Bash. ;)
Since those are my two scripting languages of choice, I'm a very happy
student :)
ps. if anyone will be in Vegas the last full weekend of July (also
known as Def Con), I believe I just qualitified to compete in their
hack-a-thon. Not that I think I'll win, mind you, nay, but it's a
huge honor just to qualify, at least for a mere mortal like me ;)
- --
Matthew Carpenter
matt at eisgr.com http://www.eisgr.com/
Enterprise Information Systems
* Network Server Appliances
* Security Consulting, Incident Handling & Forensics
* Network Consulting, Integration & Support
* Web Integration and E-Business
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCqMJTso9lqh4MragRAotTAJwMmsodBfXfQWBDdwCVNBl8nBN5SQCg1AzT
ZRHw1t51Un+V+pQPLam7duU=
=g8iX
-----END PGP SIGNATURE-----
More information about the Linux-users
mailing list