Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › Trouble with ksh script, need some advice on where to look for help.
New Posts  All Forums:Forum Nav:

Trouble with ksh script, need some advice on where to look for help.

post #1 of 2
Thread Starter 
Hey Guys

Not asking for anyone to do my homework, however, I do need some help with this. ksh script has gotten me in a little bit of a muddle. Here is the assignment that has been given to me, questions will follow:


I have struggled to understand the terminology as I have never really "scripted". I am competent in the majority of functionality of C++ and Java, however this scripting this has me a little confused.

I guess my question are.
1. What are arguments, how do I implement them?
2. What would be a generic process to script? (i guess in coding I would look at how to separate procedures and functions depending on how long)
3. How do I pickup a file, write to a file and edit with a status code or even exit with a specific input?

Maybe I'm more lost than I originally thought.

Would love some direction to a good tutorial, or anything that could help.

Thanks

KPP
post #2 of 2
First of all a bit of background is needed. Standard out, in and error (aka STDOUT , STDIN, STDERR) are file streams (so handed by the shell in exactly the same way as reading and writing files to disk) but are printing output to the screen, reading input from the keyboard and printing errors to the screen (respectively). This means you can do redirection - which is where you take screen output stream and send it to disk instead. Or take a file and send it to an application as if it's keyboard input.

ksh is one of the few shells I've not played around in much, but redirection is generally done with the greater than and less than characters. eg:
Code:
somecommand > outputfile
somecommand < inputfile

so an example of the code in a borne shell would be:
Code:
#!/bin/sh

# example.sh
# write stuff to disk
echo "this is some text" > $1
and you'd run that as follows:
Code:
./example.sh output.txt
which would write a file to disk called output.txt with the contents being this is some text

$1 is the variable name for the first parameter. $2 will be the second....and so on.


Obviously there's a lot more to your task than just this, but that should give you some grounding to research this stuff further.
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › Trouble with ksh script, need some advice on where to look for help.