find file name...in SFTP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting find file name...in SFTP
# 1  
Old 08-14-2008
Data find file name...in SFTP

Hi All,

i am using sftp script.

Here is my problem..

i have one script which should find out the exception file that has been already placed on SFTP.

now i wan to check using script whether the file name is present there or not?

i tried using find ...not working.

only ls -l (then the filename)...its working..

but i want to use some different commands which is like grep or awk or sed..like that..is there any possiblity..

can some one help me plz..

Smilie
Thanks in advance
Sha
# 2  
Old 08-14-2008
When using find you'll have to give a name or something you can identify that file with too, like with ls. Not sure what your problem is. Maybe give an example of what you have tried.

You can often check the exit code of commands with $? if they found something or not.
# 3  
Old 08-14-2008
Power

Hi ,

Thanks for your quick replay..

let me explain little bit elaborate....

i have one production box(Linux box) from there i used login SFTP server.

using some credentials like below..

sftp O4dgSFTP@ipaddres
then will ask paswd..if give

then i will be inside SFTP server.

in a daily basis i upload only error file to this SFTP server so that other person can take this and can correct it.

now if i want to check yesterday ..did i upload the error file or not?

here i could not use find command or grep or awk?

whenever i am using those commands its giving Invalid command.

hope you understood my problem now..

Thanks
Sha
# 4  
Old 08-14-2008
When logged in with sftp type "help" and you'll get the list of all commands. sftp has list of commands like ftp and you can't use shell commands in there like find etc.
For this you have either to log what you did on your side/box or have to ask the admin of the other box to add your public ssh key and check it via ssh.
# 5  
Old 08-14-2008
Thanks for you valid suggestion.... Smilie

let me try to do that through ssh..


i have one more question if you could answer!

using below command i get some filename in my unix ...

in some location ... /home/testfolder/

ls -lrt | grep -l $value *.csv > temp1.txt

i would get some out put like below
test.csv
test2.csv
test3.csv

now i want to know which one is the latest one which got generated and i need the timestamp only..is there any way that i can get...

using awk hope i may get.. like this..

ls -lrt test3.csv | awk '{print $6,$7}'

output i am getting like ...

jan 18

because using this time stamp i need to check some other files in different location as well...


Thanks
Sha
# 6  
Old 08-14-2008
Code:
ls -rt | grep -l $value *.csv | tail-1 > t.txt
ls -l < t.txt | awk '{print $6,$7}'

# 7  
Old 08-14-2008
Thanks Jim...

i got it Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find whether a particular command has failed inside an sftp script?

hi, how can i know whether a command inside an sftp script has failed or not? i have a sftp expect script #!/usr/bin/expect spawn /usr/bin/sftp abc@ftp.abc.com expect "sftp>" send "cd dir\r" expect "sftp>" send "mput abc.txt\r" expect "sftp>" send "mput def.xls\r" expect "sftp>"... (5 Replies)
Discussion started by: Little
5 Replies

2. Shell Programming and Scripting

How to overwrite a file by transferring the file using sftp?

hi, i am using sftp to transfer files between two servers, if i connect to a remote server using sftp n moves a file say "S123.txt" to the remote server, it moves successfully, but when i try to execute the same sftp script to move the same files to the same remote server, the old file is... (3 Replies)
Discussion started by: Little
3 Replies

3. Shell Programming and Scripting

Sftp : not able to print the echo statements after the sftp transfer

I had the below sftp script working perfectly but the problem is I am not able to send the echo statements . #!/bin/sh echo "Starting to sftp..." sftp admin@myip << END_SCRIPT cd /remotepath/ lcd /localpath/ mget myfiles*.csv bye END_SCRIPT echo "Sftp successfully." echo echo... (11 Replies)
Discussion started by: scriptscript
11 Replies

4. HP-UX

To find where sftp public key is installed for user

Hi All, I am facing an issue wherein a new sft public key for a user is not working on our HP-UX m/c. So i have to check where the sftp public keys for some other sample users were installed earlier in the system i.e. under which folder. Can you please help me out on this. (2 Replies)
Discussion started by: ammbhhar
2 Replies

5. UNIX for Dummies Questions & Answers

Find the latest file on remote sftp

Hi All, I need your help in finding the latest files in remote sftp and get those files to local server and process them. Please let me know I appreciate your valuable inputs. Thanks raj (7 Replies)
Discussion started by: rajeevm
7 Replies

6. Red Hat

Chroot sftp users, remote sftp login shows wrong timestamp on files

Hello, I have a weird issue, I have RHEL 5.7 running with openssh5.2 where sftpgroup OS group is chroot. I see the difference difference in timestamp on files, when I login via ssh and SFTP, I see four hour difference, is something missing in my configuration. #pwd... (8 Replies)
Discussion started by: bobby320
8 Replies

7. Shell Programming and Scripting

wanted to find both link file and ordinary file using single find command

find . -type fl o/p is only the ordinary file. where in it wont give the link files. (2 Replies)
Discussion started by: nikhil jain
2 Replies

8. Shell Programming and Scripting

SFTP-how to log individual sftp command error while executing shell script

Hi, I have situation where i need to automate transferring 10000+ files using sftp. while read line do if ; then echo "-mput /home/student/Desktop/folder/$line/* /cygdrive/e/folder/$line/">>sftpCommand.txt fi done< files.txt sftp -b sftpCommand.txt stu@192.168.2.1 The above... (1 Reply)
Discussion started by: noobrobot
1 Replies

9. UNIX for Advanced & Expert Users

Copy a file with sftp

Hi, I should copy a file from my computer in folder on a server. I use sftp account@computername and insert the password. then I write sftp> put /home/path/file to copy the file in my accont folder but this command doesn't work and it says that it couldn't find the file. Hope I was... (5 Replies)
Discussion started by: jborges
5 Replies

10. Shell Programming and Scripting

SFTP +Find

Hi, I am using sftp to loging to a remote server, I need to remove all the files on the remote which are older than n days and of type *.txt*. I tried "find . -type f -name "*" -mtime +15" > /tmp/temp.$$ but find command does nt work on the sftp. can u pls help me out Thanks ... (6 Replies)
Discussion started by: vikramsnest
6 Replies
Login or Register to Ask a Question