Sponsored Content
Top Forums Shell Programming and Scripting After FTP unable to move file to other location Post 302560111 by rajubollas on Thursday 29th of September 2011 02:03:17 AM
Old 09-29-2011
Afer FTP unable mv file to other location

This is what i am trying, first i have to run data stage job for Aix server and it will generate a file that file will mv with currentdate stamp (PSIC_FIlename_29092011130105.txt) then compress and FTP file and move it archive folder this should done for each step.
Code:
#!/bin/sh
# This script will put QIS2 data into the Falt files for PSIC activities.
ScriptOutput=/QIS2FTP/dsclientprod/home/scripts/ScriptRunInfo.txt
StartTime=`date +%d-%m-20%y" "%H:%M:%S`
JobInfoScript=/QIS2FTP/dsclientprod/home/scripts/JobStatus.sh
# for debugging purposes only
set -x
# import my environment
. /QIS2FTP/dsclientprod/home/my.env
weeklyLoadDirectory=/QIS2FTP/dsclientprod/development
# variables
scriptsDirectory=/QIS2FTP/dsclientprod/home/scripts/weekly
ChooseNumber=10
# move to the telematics directory
cd $weeklyLoadDirectory/
today=`date`
echo "START: PSIC starting for $today. Processing"
#start STEP 4
status=`dsjob -report QIS2 PSIC_COUNTRY BASIC | grep status | awk -F= ' { print $2; } ' | awk ' { print $1; } '`;
if [ "x3" = "x${status}" ]
then
dsjob -run -mode RESET -wait -jobstatus QIS2 PSIC_COUNTRY
fi
echo dsjob -run -mode NORMAL -wait -jobstatus -warn 999999999 QIS2 PSIC_COUNTRY
dsjob -run -mode NORMAL -wait -jobstatus -warn 999999999 QIS2 PSIC_COUNTRY
sh $JobInfoScript "PSIC" PSIC_COUNTRY
cd /QIS2FTP/dsclientprod/PSIC/
mv PSIC_Country_DataFile.txt PSIC_Country_DataFile_`date '+%Y%m%d%H%M%S'`.txt
compress PSIC_Country_DataFile*.txt
Cfile=`ls -1 PSIC_Country_DataFile*`
for i in $Cfile
do
#FTP Script
#######################################
#Scripted By Raju B on 14/Sep/2011 #
#Before doing FTP Uncomment Variables #
#######################################
rm /QIS2FTP/dsclientprod/PSIC/FTP.log
FileDate=`date '+%Y%m%d'`
Host_name="r89.gmail.com"
USER_ID="yyyy"
PWD="xxx"
echo "Host Name is : $Host_name" >>FTP.log
echo "User_id is : $User_id"
echo "Password is : $Pwd"
ftp -n $Host_name <<End-Of-Session
user $USER_ID $PWD
lcd /QIS2FTP/dsclientprod/PSIC/
cd /card30/outputs/na/aware/
type binary
put $i
bye
End-Of-Session
#exit;
 
 
if [ $? -eq 0 ]
then
echo "Successfully FTP'ed the file from remote server..." >>FTP.log
else
echo "Error has occured while FTP'ing the file from remote server" >>FTP.log
fi
echo "End of the script..." >>FTP.log
#quit;
mv $i /QIS2FTP/dsclientprod/PSIC/archive/
#Here i am getting en error and local directory is will changing here and it is not going to step 5 level
done
##end step 4 return code
echo "STEP 4 FINISHED."
#start STEP 5
status=`dsjob -report QIS2 PSIC_CITY_BASIC | grep status | awk -F= ' { print $2; } ' | awk ' { print $1; } '`;
if [ "x3" = "x${status}" ]
then
dsjob -run -mode RESET -wait -jobstatus QIS2 PSIC_COUNTRY
fi
echo dsjob -run -mode NORMAL -wait -jobstatus -warn 999999999 QIS2 PSIC_COUNTRY
dsjob -run -mode NORMAL -wait -jobstatus -warn 999999999 QIS2 PSIC_COUNTRY
sh $JobInfoScript "PSIC" PSIC_CITY
cd /QIS2FTP/dsclientprod/PSIC/
mv PSIC_Country_DataFile.txt PSIC_City_DataFile_`date '+%Y%m%d%H%M%S'`.txt
compress PSIC_City_DataFile*.txt
Cfile=`ls -1 PSIC_City_DataFile*`
for i in $Cfile
do
#FTP Script
#######################################
#Scripted By Raju B on 14/Sep/2011 #
#Before doing FTP Uncomment Variables #
#######################################
rm /QIS2FTP/dsclientprod/PSIC/FTP.log
FileDate=`date '+%Y%m%d'`
Host_name="r89.gmail.com"
USER_ID="yyyy"
PWD="xxx"
echo "Host Name is : $Host_name" >>FTP.log
echo "User_id is : $User_id"
echo "Password is : $Pwd"
ftp -n $Host_name <<End-Of-Session
user $USER_ID $PWD
lcd /QIS2FTP/dsclientprod/PSIC/
cd /card30/outputs/na/aware/
type binary
put $i
bye
End-Of-Session
#exit;
 
 
if [ $? -eq 0 ]
then
echo "Successfully FTP'ed the file from remote server..." >>FTP.log
else
echo "Error has occured while FTP'ing the file from remote server" >>FTP.log
fi
echo "End of the script..." >>FTP.log
#quit;
mv $i /QIS2FTP/dsclientprod/PSIC/archive/
done
##end step 5 return code
echo "STEP 5 FINISHED."
set +x


Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

 

Last edited by Franklin52; 09-29-2011 at 03:53 AM.. Reason: Please use code tags and indentation
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to put file from one ftp to another ftp location

hi, I have one file located in ftp.I want to place that file in different ftp location. Up to now i am doing it manually using get command and copying that file in to my local system and then putting that file in different ftp using put command. now i want to automate that using shell... (1 Reply)
Discussion started by: prasee
1 Replies

2. UNIX for Dummies Questions & Answers

Unable to copy or move file

I am trying to move a file that is in the root directory. I suspect it is an old file created by someone when the system was installed. I am testing accessing the file by doing a copy but the command does not find the file. I am operating as root. We are HP-UX B.11.23 I do long listing and... (3 Replies)
Discussion started by: phcorn
3 Replies

3. Shell Programming and Scripting

ftp: get list of file to get. Retrieve and move them

Hi, I need to get multiple files from an ftp server. Once the files have been downloaded, I need to move them to a different directory on the ftp server. I don't know of a command that would enable me to get a file and then move it (assuming I don't know the exact file name) within ftp. I think... (10 Replies)
Discussion started by: bbabr
10 Replies

4. Shell Programming and Scripting

Move files from one location to another

Hi, I wanted to check how to move files from one location to another based some particular date. Example I want to move /data/NewJersey folder to /home/scripts/NJ ( including all the files and subfolders within it ), but only which are older than say 8th February 2010. script , awk, sed (... (4 Replies)
Discussion started by: rudoraj
4 Replies

5. HP-UX

[Solved] Unable to rename file in ftp server .Net:FTP perl

Hello All, I am trying to connect to ftp server and get the files. Also i need to rename the file in other ftp dir. rename method is not allowing me to rename the file in other dir. When i tried copy command by using net::FTP:FILE then perl says it is not installed. Can some body help me to... (2 Replies)
Discussion started by: krsnadasa
2 Replies

6. Shell Programming and Scripting

How to move the older than 30 file to another ftp server

Hi All I need to move the older than 30 days file to another ftp server. I have source structure like this Files folder Folder1 Folder2 Folder3 I need to create same Target structure and I need to move the older than 30 day file to another ftp server, can you please suggest me how I develop... (1 Reply)
Discussion started by: murari83.ds
1 Replies

7. Shell Programming and Scripting

How to find a word and move it a specific location in xml file using perl?

Hi friends, I have one XML file having below structure :- INput XML file :- <?xml version="1.0" encoding="UTF-8"?> <START> <A=value1> <attr name1="a1"> </A> <B=value2> <attr name2="b1"> <attr name3="c1"> </B> </START> output xml file should be === (3 Replies)
Discussion started by: harpal singh
3 Replies

8. UNIX for Advanced & Expert Users

Want to download a latest file with current date from FTP location

Dear Friends, I need help to write a shell / perl script to download the files from FTP location, having different file names (date inside the file name). Example: Mar 5 09:24 cfx_03052013_return_file.txt Mar 6 02:13 cfx_03062013_return_file.txt Mar 7 06:40... (3 Replies)
Discussion started by: Praveen Pandit
3 Replies

9. Shell Programming and Scripting

How to move a file in ftp command to other location?

hi, when i do ftp from unix to laptop which is running a windows os, it lands in a root folder. can i move a file from this root ftp folder to any other location in my laptop say , c:\files\ folder? i used rename command inside ftp , but it says incorrect parameter. (5 Replies)
Discussion started by: Little
5 Replies

10. Linux

Get all the files from a FTP location with previous week's dates in the file names using Linux

I have a weird requirement where I have to get the files from a FTP(Lets say FTP1) location and place it on my current FTP(Lets say FTP2) location. The issue is, these are daily files (in a pattern Sales_YYYYMMDD_report.csv) and are placed every day on FTP1 and my process usually runs on Monday(eg.... (2 Replies)
Discussion started by: dhruuv369
2 Replies
All times are GMT -4. The time now is 08:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy