I'm no killer in shell scripting, that is why I've searched and found a little script that explained how to do what I wanted to do : a FTP transfer from distant servers. I adapted it cause as such, it didn't work.
As I needed to do some very simple shell commands (erase and rename of files) after the transfer was being done, I added some personnal but very basic sript lines.
So the result is the following :
the adapted SFTP lines in the spawn do the job
but the renaming and erasing parts don't.
See below the code :
and I get this error message :
Quote:
sftp> invalid command name "rm"
while executing
"rm -f /home/ess_tms/temp/JTMSF/*.gz"
(file "./test2.ksh" line 24)
The way I understand this error message is that, somehow, it tells me I'm not in a shell command window, I'm still in a SFTP kind of session. Which seems to be different from a shell command session (really )
This is why it was expecting SFTP or spawn commands and cannot interpete shell orders.
To make it work, I'd need to get out from this SFTP/Spawn command session, but :
I don't know if my analysis is correct
if it is, I don't know how to do so
Is there one of you who could help me on that little crappy script of mine ?
Could you create a key to allow password-less authentication? if you can, then expect can be removed and you can use the -b flag of sftp to run the commands you want.
It might just be that the sftp does not exist. I might have missed it, but I don't see a quit in your code.
Hi All,
I have below script which is just trying to sftp transfer a file to another server with 'expect' option.
I have expect installed on the instance.
Below is the script:
#!/usr/bin/expect
spawn sftp oracle@<HOST>
expect "password:"
send "<mypassword>\n"
expect "sftp>"... (6 Replies)
Hi,
I have a problem with the spawn execution with expect.. i have done the code for expect in a separate file and i am calling the this execution from the bash script.. as given below..
-bash-4.1$ cat main.sh
#!/usr/bin/bash
./spawn.exp
==========================
-bash-4.1$ cat... (2 Replies)
hi,
i am having 2 linux boxes as source and 1 linux box as destination.i want to create a shell script containing code to transfer a csv file from either of the 2 linux boxes (file will be present in just one box, i need to check both the boxes to see which box has the csv file) to 3rd linux box... (1 Reply)
Hi all,
I have a script that runs sftp with expect so I can login and send a file in a cronjob. I've installed this on a couple other servers and it has been fine. However, this time on this machine, it seems to be giving me an issue. It won't move past the spawn sftp command and return a... (3 Replies)
Hi,
The script didn't continue as "20130109" folder is already created on the destination server. Please help.
Entry in script:
cat > $filebatch << __EOF__
mkdir $current_date
mkdir $current_date/$fpdomain
cd $current_date/$fpdomain
ls -l
__EOF__
Error:
sftp -b... (12 Replies)
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)
Hi,
I am new this forum. I request you peoples help in understanding and finding some solution to my problem.
Here it goes:
I need to perform this set of actions by writing a shell script. I need to read a config file for the bunch of processes to execute.
I need to fecth the pid of... (4 Replies)
Hi All,
Please let me know how do I execute some of the shell commands like cat, find ,grep within sftp.
Any help in this regard would be greatly appreciated.
Thanks, (5 Replies)
I want to be able to run a script on one server, that will spawn another shell which runs some commands on another server..
I have seen some code that may help - but I cant get it working as below:
spawn /usr/bin/ksh
send "telnet x <port_no>\r"
expect "Enter command: "
send "LOGIN:x:x;... (2 Replies)