Sponsored Content
Top Forums Shell Programming and Scripting How I can capture the last file in a directory in windows Post 302411136 by rechever on Wednesday 7th of April 2010 06:06:01 PM
Old 04-07-2010
Well, I am getting the following:
Here is the directory in unix
N:\orgs\Financial Aid\CSSIDOCLoad (explore)
here is my piece of code:

Code:
CDRemoteDir= 'cd N:\orgs\"Financial Aid"\"CSSIDOCLoad" ';
UpLoadFileName== '$(ls -rt | tail -1)';
echo $UpLoadFileName;

It is not finding the directory
Code:
spinel:/u02/sct/banner/bandev2/xxxxx/shl$ sh idoc_ftp_finaid.shl 'DEV2' 
idoc_ftp_finaid.shl[39]: cd N:\orgs\"Financial Aid"\"CSSIDOCLoad" :  not found
idoc_ftp_finaid.shl[40]: $(ls -rt | tail -1):  not found

I changed the real name for xxxx
Again I have files in that directory that are like 3526_419184.dat 3526_ is is a constant
but the rest like 419184 are different I want to capture the last file that was move to that directory in UpLoadFileName, so I can FTP later

here is the rest of the code
Code:
 
# 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 directory in remote machine
echo ${CDRemoteDir}

# Change local directory in local machine
### echo lcd $LocalDir

# Transfer file
echo get $UpLoadFileName

# End ftp session
echo quit

) | ftp -vin $RemoteHost >>${LF1} 2>>${LF2}

# End of FTP Process

if test $? -eq 0
then
  echo "Successfully executed FTP"  >>${LF1} 2>>${LF2}
else
  echo "Error: could not execute FTP" >>${LF1} 2>>${LF2}
  echo " " >>${LF1} 2>>${LF2}
  echo "Script Ended." >>${LF1} 2>>${LF2}
  exit 1
fi


Last edited by pludi; 04-08-2010 at 01:51 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

moving files from a unix directory to a windows directory

Any body any ideas i'm failry new to this so any help would be appreciated. Cheers Steve (2 Replies)
Discussion started by: gleads
2 Replies

2. UNIX for Advanced & Expert Users

Capture Value from file

I have a file in the following Format Fundid: 100-BankA AccountNumber Balance 1 200 2 300 3 400 FundId:123321-BankB AccountNumber Balance 1 200 3 100 ........... I can have N number of funds. (1 Reply)
Discussion started by: kris01752
1 Replies

3. Shell Programming and Scripting

capture the file name

I am trying to capture the file name(which is not of fixed length) and put it in a variable. It is working in unix whereas when I am running the same script in Informatica it is not giving me the desired output. But when I comment the option(find the file name) then it is working fine. It can... (4 Replies)
Discussion started by: Mandab
4 Replies

4. Shell Programming and Scripting

Script to capture new lines in a file and copy it to new file

Hi All, I have a file that gives me new line/output every 5 minutes. I need to create a script that capture new line/output besides "IN CRON_STATUS", in this case the new output is "begin ------ cron_status.sh - -----------". I want this script to capture the line starting from "begin ------... (0 Replies)
Discussion started by: fara_aris
0 Replies

5. Shell Programming and Scripting

capture output of file and send last string thereof to new file

Hello, If I run a program from within shell, the output is displayed in the command line terminal. Is there a way I can capture that output and choose only the very last string in it to send it to a new file? Thank you (6 Replies)
Discussion started by: Lorna
6 Replies

6. Shell Programming and Scripting

Move a file from windows directory to unix directory

Move a file from windows directory to unix directory, is this possible? if it is, can someone help me on this? Thanks! God bless! (1 Reply)
Discussion started by: kingpeejay
1 Replies

7. UNIX for Dummies Questions & Answers

Copy directory from Linux to Windows

Hola a todos, soy realmente nuevo programando en bash, y aśn estoy encontrando bastantes baches :o, mi pregunta es simple, supongo, alguien podria decirme si existe una manera facil de copiar un directorio de un server a otro?, sucede que en un server(server1) tengo los backup de las bases de... (7 Replies)
Discussion started by: yeestrada
7 Replies

8. Programming

Copy directory from solaris to windows.

Hi All I am new to Unix/sloaris. I want to copy a directory (which conatins further sub directories and files)from sloaris to my windows.I am using PuTTy for it. please any one guide me how to do this or share with me some piece of script. It will be very regarded Best Wishes MIS. (1 Reply)
Discussion started by: MIS
1 Replies

9. Solaris

Copy directory from solaris to windows.

Hi All I am new to Unix/sloaris. I want to copy a directory (which conatins further sub directories and files)from sloaris to my windows.I am using PuTTy for it. please any one guide me how to do this or share with me some piece of script. It will be very regarded Best Wishes MIS. (3 Replies)
Discussion started by: MIS
3 Replies

10. AIX

Samba 3.6 on AIX 7.1 - Windows 10 Access to AIX file shares using Active Directory authentication

I am running AIX 7.1 and currently we have samba 3.6.25 installed on the server. As it stands some AIX folders are shared that can be accessed by certain Windows users. The problem is that since Windows 10 the guest feature no longer works so users have to manually type in their Windows login/pwd... (14 Replies)
Discussion started by: linuxsnake
14 Replies
FTP_FPUT(3)								 1							       FTP_FPUT(3)

ftp_fput - Uploads from an open file to the FTP server

SYNOPSIS
bool ftp_fput (resource $ftp_stream, string $remote_file, resource $handle, int $mode, [int $startpos]) DESCRIPTION
ftp_fput(3) uploads the data from a file pointer to a remote file on the FTP server. PARAMETERS
o $ftp_stream - The link identifier of the FTP connection. o $remote_file - The remote file path. o $handle - An open file pointer on the local file. Reading stops at end of file. o $mode - The transfer mode. Must be either FTP_ASCII or FTP_BINARY. o $startpos -The position in the remote file to start uploading to. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 ftp_fput(3) example <?php // open some file for reading $file = 'somefile.txt'; $fp = fopen($file, 'r'); // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // try to upload $file if (ftp_fput($conn_id, $file, $fp, FTP_ASCII)) { echo "Successfully uploaded $file "; } else { echo "There was a problem while uploading $file "; } // close the connection and the file handler ftp_close($conn_id); fclose($fp); ?> SEE ALSO
ftp_put(3), ftp_nb_fput(3), ftp_nb_put(3). PHP Documentation Group FTP_FPUT(3)
All times are GMT -4. The time now is 09:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy