Hi!
I am still fairly new to shell programming, but I have taken an interest to it and want to try some new stuff.
I intend to make a shell script (using bash) to read a file on a remote system, then do some work on it on the local system and display it.
In the long run I want to have a script that does this automatically for me and I only need to initiate the script and it does updates say every 10 minutes or atoher user defined time intereval (I guess spesefied as an argument as well eventually)
But first things first. I need to be able to read the file and manipulate it. More spesific it is a comma seperated file contianing some valuses I am interested in. Not all of them, but value 2, 7 and 13 from each line I want to list on my local system.
I have so far desigend my script to take in the arguments of IPadress and filename:
#!/bin/sh
# Look for args, if worng number of agruments print error and exit
# ARGS is number of arguments scripts expects
ARGS=2
if [ $# -ne $ARGS ]
then
echo "$0:Error, missing or too many arguments!"
echo "Usage: $0 IP filename"
exit 1
fi
IPADRESS=$1
FILENAME=$2
echo $IPADRESS
echo $FILENAME
As you see its so far very, very basic and not really useful as is. My next "milestone" so to speak is reading the file from a remote system. I do not want to manipulate the remote file at all, only read it and get it to the local system, there I will do the manipulation and print what I want, in a manner that disturbed the remote system the least.
But I am not entierly sure how to read the file from the remote system in a good way (after all I am still really new at shell scripting, I have only ever done some c++ programming before). Should I make a copy of it localy and use that further in my script? Or read the information I want form the remote system and only get thoose values to work with further?
I would appreciate some helps and hints here as to how to proceed. Assume I am a total newbie (and some examples if any would also help me understand)
If I have posted in the wrong section, I am sorry, but this looked to be the place were such things belong.
(Sorry if my english is not top notch, its not my native language)