The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-19-2009
rechever rechever is offline
Registered User
  
 

Join Date: May 2009
Posts: 20
FTP help

I need to FTP a file
from
LocalDir= 'cd orgs /"Financial Aid"/"MSS"/"0910"/"FTP" ';
to
CDRemoteDir="/u02/sct/banjobs";

The file in th local directory is created like 07130900.SUP the .SUP is always there, but the 07130900 (change everyday with the date, look at the format 07130900, how I can add code in this script, so I know that everyday is going to FTP the last file with the .SUP EXTENSION
Code:
#! /bin/sh
#
#**************************************************************************
# Script:  miis_ftp.ELM_SUP.shl
#
# Author:  
# Date: 7/17/2009
#
# Purpose:
#   
# files are downloaded from ELM,named xxxxxx00.SUP to 
 #  ="/u02/sct/banjobs";
#
# Directory Location for script:
#        #
# Special Notes:        This shell script is called from XXX
#                   run in job submission
#
#
# Modifications:
#  Date   Author          Description
#
# 
#
#**************************************************************************
#
FILE_NAME="$1";

MPATH=$BANNER_HOME;
ScriptName="miis_ftp.ELM_SUP.shl";

UpLoadFileName1=${FILE_NAME};
LocalDir= 'cd orgs /"Financial Aid"/"MSS"/"0910"/"FTP" ';
 
RemoteHost="middfiles.xxxx.edu";
###look at this
RemoteUser="XXXXX_finance";
RemotePass="XXXXXX+";
CDRemoteDir="/u02/sct/banjobs";

TMode="ascii";                          # Transfer mode

TodayDate=`date`;
echo "\nActivities for FTP proscess:";
#========================================================================================
# Change the directory to one contains the file to be transported
cd $LocalDir;

#----------------------------------------------------------------------------------------
# Initiate the FTP process
# Loop through remaining parameters to create ftp commands.
(
# Enter user-name and password in host machine
echo "user $RemoteUser $RemotePass"
# Set transfer mode
echo $TMode
# change remote directory
echo ${CDRemoteDir}
# Change local directory in local machine
##echo lcd $LocalDir

Last edited by vgersh99; 07-20-2009 at 12:14 PM.. Reason: code tags, PLEASE!
Bits Awarded / Charged to rechever for this Post
Date User Comment Amount
07-20-2009 vgersh99 added code tags - charged 3K bits -3,000
  #2 (permalink)  
Old 07-19-2009
candlejack's Avatar
candlejack candlejack is offline
Registered User
  
 

Join Date: Nov 2008
Location: /dev/meh
Posts: 53
You can get the date format in the way you specified using this:

Code:
date "+%m%d%y"
So you could set the filename like this:

Code:
FILENAME=`date "+%m%d%y"00.SUP`
  #3 (permalink)  
Old 07-19-2009
rechever rechever is offline
Registered User
  
 

Join Date: May 2009
Posts: 20
something like this?


Code:
ScriptName="miis_ftp.ELM_SUP.shl";
UpLoadFileName=`date "+%m%d%y"00.SUP`;
NewName= "eluppdtop.dat" ;
After I got the file, I need to change the name to eluppdtop.dat, is this correct

also
will this work, knowing that the file is in a directory in windows.. It is
going from a drirectory in windoxs to UNIX \

Code:
# Error Handling Function
function ErrorHandle
{ 
# if type is 1, then the file does not exist or unreadable
if [ $type -eq 1 ]
then
echo "File "$UpLoadFileName" does not exist or unreadable" >> $LogFile;
echo "Subject: Error in Running Script\n Error in uploading file script "$ScriptName". File "$UpLoadFileName" does not exist or unreadable" > EmailMessage;
sendmail -F " File Upload" $EmailAddress < EmailMessage;
rm EmailMessage;
fi
# if type is 2, then the file has zero size
if [ $type -eq 2 ]
then
echo "File "$UpLoadFileName" has a zero size value" >>$LogFile;
echo " Subject: Error in Running Script\n Error in uploading file script "$ScriptName". File "$UpLoadFileName" has a zero size value" > EmailMessage;
sendmail -F "The eluppdtop.dat File Upload" $EmailAddress < EmailMessage;
rm EmailMessage;
fi

Last edited by vgersh99; 07-20-2009 at 12:15 PM.. Reason: code tags, PLEASE!
  #4 (permalink)  
Old 07-20-2009
candlejack's Avatar
candlejack candlejack is offline
Registered User
  
 

Join Date: Nov 2008
Location: /dev/meh
Posts: 53
Once you have the file you can name it anything you wish. Also, it shouldn't be a problem that the FTP server is running on a Windows box.

Good luck
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:36 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0