I am trying to learn to script.
first I have 2 server, A and B.
A with IP 192.168.82.22. B with IP 192.168.82.44.
Both with login user admin and password admin.
server A will generate a file every day with name gg.log under /app/gg/20171002.log. I wish to write a script to copy the file zip it and send to server B under the folder ITlog with one day before.
I have a few to questions pose in response first:-
Is this homework/assignment? There are specific forums for these.
What have you tried so far?
What output/errors do you get?
What OS and version are you using?
What are your preferred tools? (csh, ksh, bash, Perl even?)
What logical process have you considered? (to help steer us to follow what you are trying to achieve)
Do you have authentication set up to copy the file manually, or some sort of disk share that they both see?
Does this need to be scheduled, and if so, what tools do you have available other than cron?
Most importantly, What have you tried so far?
There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.
We're all here to learn and getting the relevant information will help us all. I'm sure we can get this sorted.
Hi Robin,
Please see my reply.
Is this homework/assignment? There are specific forums for these.
This is my assignment.
What have you tried so far?
So far i have search on google and try to get some info.
What output/errors do you get?
I have not try any yet.
What OS and version are you using?
Aix 7.1
What are your preferred tools? (csh, ksh, bash, Perl even?)
Ksh
What logical process have you considered? (to help steer us to follow what you are trying to achieve)
i am trying to copy a file generated by the app and ftp it to another workstation to analyse the data.
Do you have authentication set up to copy the file manually, or some sort of disk share that they both see?
not too sure.
Does this need to be scheduled, and if so, what tools do you have available other than cron?
crontab to be use.
Most importantly, What have you tried so far?
just getting some concept to run this on our development server.
Okay, so if you were to do this manually, step by step, what would you do? Would it be something like:-
Change to the directory of the source file
Start FTP/SFTP to the target server
Provide login credentials where requested
Within FTP/SFTP, change to the target directory
Issue a put to transmit the file
Quit FTP/SFTP
It could also be done the other way round, i.e connect from where you want to get the file to back to the source and get the file.
Are either of these a suitable structure? If so:-
Do you have a fixed filename to send/receive?
Do you have credentials?
Will you be using FTP, SFTP or something else?
How far can you get with your code before you get stuck?
Okay, that is a decent start. I would suggest moving the credentials out of the script. If you can read the script, you can see the credentials and therefore access data that maybe should be secure. Additionally, if you have several scripts with these details in and you need to change them (e.g. you decide that having the password the same as the account is not actually very secure) then you have to change it in everyone of your scripts else you will get failures.
Without a -n flag, FTP will look for a file called .netrc in the home directory of the person running it. The format is defined in the man netrc page. You don't need to include all the fields.
This does some directory creation before putting all the files that match the string given. I'm not sure if this is what you want. Perhaps this would be neater:- /home/rbatte1/.netrc
The second line uses the short DNS name, which is more descriptive so may be better long term.
/home/rbatte1/my_ftp_script_example
Your description was a little vague, so I've guessed at what you mean for the various directories.
Hi Robin,
There is a changes on the scenario, lets say I have a development server A running AIX 7.1 with ip 192.168.82.22 and a windows workstation with ip 192.168.82.44 and the ftp connection is opened.
for server A under the /app/gg/it there will be file generated every hour and another fie generated daily,what i need to do is to find the files lets say from may 2017 till yesterday and gzip it then ftp it over to the workstation assuming the ftp is ok. how should my scripts looks like?
Here I created a script but don't know its was right or wrong as I do not have a chance to test on the real development environment.
Last edited by leecopper; 10-06-2017 at 05:56 AM..
Reason: Converted to formatted numbered list
Hi All,
Can you please let me know what I missed in the below function? Whenever I try to execute the script i am getting
syntax error at line 101 : `fi' unexpected
Function is
function DELNWE5O {
export ORACLE_HOME=/ora00/app/oracle/product/11.2.0/grid_1
export... (9 Replies)
I want to run a script that checks the env to see if I'm in a test or prod environment. From the command line I enter echo $host and it returns host name and I can tell by the name if I'm in test or prod. When I run the command from a script I get "not found" What's wrong with the script?
if ... (2 Replies)
Hello gurus
I am looking for a script :
We need to generate a file list created by user id on a AIX box.
Criteria 1: other than userid : dwimpid & aiadmin
Criteria 2: Files older than 2 months ( it can be any user id ).
File Path to Look: /project and /project1
Thx
silu (7 Replies)
I got a task to do today, I want to write a script for the following
1) Archive log more than 2 days old
2) Number of days the current Archive logs present
3) Total number of archive logs
4) Size of each archive log
5) When was last successful backup happened?
Can I get a general script... (8 Replies)
I am looking for a script which does the following
Script will run daily.
1.It will get snapshot off all filesystems including nfs mounts, automounts and clearcase mounts.
2.Then it will compare new snapshot with the snapshot created in the previous run.
3.If filesystem exists in... (20 Replies)
Hi,
Below is the code for my script
#!/bin/ksh
for file in "file1.txt" "file2.txt" "file3.txt" "file4.txt"
do
L="$(tail -1 $file)"
NUM=${L%%|*}
DAT=${L##*|}
echo $NUM
echo $DAT
done
Now here,suppose for file1.txt
L will have data like 56|06-07-2010
So, it should be (7 Replies)
I am trying to create a script to manipulate numerous file and at first I thought it would be a simple task but at this point i am ready to break my computer! I am new to unix scripting so hopefully someone out there thinks this is super easy and can help me out!
A sample of the problem file is... (2 Replies)
I have the file as below
server1 no dr aix 5300-05-03 9119-595 20-18888 yes ftp-eagle
server2 no dr aix 5300-05-03 9119-595 20-18888 yes ftp-eagle
server3 yes dr aix 5300-05-03 9119-595 20-18888 yes ftp-eagle
server4 ... (1 Reply)
Hi I need to insert a page break into a file based on matching a phrase in the file. :confused: I am doing this with a ksh script on a Unix box.
Any help would be greatly appreciated.
Thanks (5 Replies)