Sponsored Content
Top Forums UNIX for Advanced & Expert Users Error while renaming the file in SFTP Session Post 302952007 by sparks on Wednesday 12th of August 2015 01:08:27 PM
Old 08-12-2015
Error while renaming the file in SFTP Session

Hi All

Below is the script I am trying to execute to rename a file in an SFTP session.

It is in GNU/Linux.

This script is for generic use and so I am passing arguments. Everything in the script works fine except "reading the filename in SFTP session"

In the below script the $Remote_server_source_path is read properly. The filename is read from the while loop. When i echo the filename, it is read correctly, but somehow it is not read in sftp session

Please help!!

Code:
#!/bin/sh
#set -v
file_path=$1
Remote_server_source_path=$2
Dest_path=$3
File_pattern=$4
LOGIN=$5
echo "File path at Laclede End :"$file_path
echo "Path FROM where the file has to be moved :" $Remote_server_source_path
echo "Path TO where the file has to be moved :" $Dest_path
echo "SFTP server Login : " $LOGIN
cd $file_path
echo $pwd
DIRNAME=$(echo `pwd` | rev | cut -d "/" -f1 | rev)
echo $DIRNAME
ls -ltr $File_pattern > tempfilelist
count=`cat tempfilelist | wc -l`
echo "Number of files found: " $count
cat tempfilelist | while read line
do
#echo $line
echo "Filename to be moved : "
filename= echo $line | awk '{print $9}'
echo $filename
sftp $LOGIN  << EOF
cd $Remote_server_source_path
pwd
rename "$Remote_server_source_path/$filename" "$Dest_path/$filename"
bye
EOF
done

---------- Post updated at 09:08 AM ---------- Previous update was at 09:07 AM ----------

I also tried removing the qoutes . It still doesnt work.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

sftp problem with user id of no telnet session allowed

We used to have a ftp user id with no telnet session allowed in server side. We used this ftp user id in script by transferring file from client to Server. Currently we need to implement sftp to replace ftp. We have tested few round and working fine by using sftp with normal user id (allow... (2 Replies)
Discussion started by: superdougl
2 Replies

2. Shell Programming and Scripting

Error while renaming file

After running he following command to rename a file: # mv 'Linux CPU (EDF).sh' LinuxCpu(EDF).sh I am getting the following error: -bash: syntax error near unexpected token `(' Why is this happening? (2 Replies)
Discussion started by: proactiveaditya
2 Replies

3. Shell Programming and Scripting

Catch error from SFTP session

We have script running to SFTP some file to the remote server. The problem is the SFTP transfer returns an exit code of 0 even if there is permission error during file transfer, connection refuse (like when sftp server is down), thus, returning the status of the script as success. I was thinking... (3 Replies)
Discussion started by: The One
3 Replies

4. Solaris

Cygwin X Server error: xdmcp fatal error session failed session 23 failed for display

Hi, i got the following error when i tried to access the cygwin x server from a windows XP PC. "xdmcp fatal error session failed session 23 failed for display" Alternatively, when i tried to access the same Cygwin X Server from another windows XP PC which is on a different LAN... (3 Replies)
Discussion started by: HarishKumarM
3 Replies

5. Shell Programming and Scripting

Execute shell script within sftp session

Hi all , can any one tell me how to run a script within a sftp session. let me tell u in bit clear way : After I connected to sftp location , cd ing to some directory then I need to execute a one script. Please tell me if u have any idea on this . Looking forward to your reply guys... (1 Reply)
Discussion started by: sravan008
1 Replies

6. Shell Programming and Scripting

Renaming a file while using SFTP

Hi All, I have a script which works perfectly for using SFTP commands. I use SFTP -b batchfile remoteuser@remoteserver. This batch file contains a command cd /dir1 put file1 I am wondering if there is a flag to rename a file on Remote server. I see the option rename file1... (6 Replies)
Discussion started by: Hangman2
6 Replies

7. Shell Programming and Scripting

bulk renaming of files in sftp using script

Hi, Am using sftp (dsa method) to transfer 20 files from one server(sftp) to another (local). After the transfer is complete the files in the sftp server has to be renamed from .txt extension to .done extension ( aa.txt to aa.done, bb.txt to bb.done and likewise...). I tried rename command... (4 Replies)
Discussion started by: Sindhuap
4 Replies

8. Solaris

sftp file renaming

Hi Admins, I am trying to get a file with different name including date format using sftp. For example --> get test.bak auto`date +"%Y%m%d"`err Here i am trying to get the file test.back with name auto20120126err But file is copied with the name auto`date --> date is not printing... (1 Reply)
Discussion started by: newaix
1 Replies

9. Shell Programming and Scripting

mkdir -p option in SFTP session

Hi, I am trying to create more than one directory by using -p option in SFTP session. But it created a directory named -p and ended. It didn't throw any error. sxxxxxxx:(abc)/test> sftp abcuser@zxxxxxxx Connecting to zxxxxxxx... Password: sftp> pwd Remote working directory: /test... (3 Replies)
Discussion started by: gthangav
3 Replies

10. Shell Programming and Scripting

SFTP batch not renaming file with "put"

I have a .ksh script that creates an sftp batch file and runs it through sftp. It works except for one thing. If I try to "put" to a different name, it doesn't use the specified remote name...it still "puts" the original local name. I've tried both of these, and neither work...it will always... (4 Replies)
Discussion started by: dbiggied
4 Replies
echo(3XCURSES)						  X/Open Curses Library Functions					    echo(3XCURSES)

NAME
echo, noecho - enable/disable terminal echo SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int echo(void); int noecho(void); DESCRIPTION
The echo() function enables Echo mode for the current screen. The noecho() function disables Echo mode for the current screen. Initially, curses software echo mode is enabled and hardware echo mode of the tty driver is disabled. The echo() and noecho() functions control soft- ware echo only. Hardware echo must remain disabled for the duration of the application, else the behavior is undefined. RETURN VALUES
Upon successful completion, these functions return OK. Otherwise, they return ERR. ERRORS
No errors are defined. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
getch(3XCURSES), getstr(3XCURSES), initscr(3XCURSES), libcurses(3XCURSES), scanw(3XCURSES), attributes(5), standards(5) SunOS 5.11 5 Jun 2002 echo(3XCURSES)
All times are GMT -4. The time now is 03:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy