ksh script to send .jpg to remote server through ftp script - shell

Hello just created a ksh script to ftp .jpg image to a remote server but the images are showing in bad qulity when I send them with the script is there a line I should fix to not alterate the image a deliver the image to the remote server like the original please help, should I add the bin line?
cp -r /path/dir/*.jpg /path/dir
cp -r /path/dir/*.JPG /path/dirREMOTE
USER='xxx'
PASSWORD=xxx'
source_dir='cd /path/images/'
target_dir='cd /images'
ftp -n xxx.xx.xxx.xx <<_FTP
quote USER $USER
quote PASS $PASSWORD
lcd /xxx/xxx/
cd /xxx
mput *.jpg
bye
_FTP
/home/test_scripts/test_script9.sh
/home/test_scripts/test_script7.sh
exit
enter code here

Related

Upload sites files and folders via ftp bash

I need a script to upload files of sites with directories to hosting via ftp.
I try to create a script, but it doesn't work. NO files are on the server. Can you help me, please?
My script
#!/bin/bash
HOST='ip_address'
USER='user'
PASSWD='password'
SERVER_FOLDER='/site'
cd /local_folder_with_sites_files
ftp -in <<END_SCRIPT
open $HOST
user $USER $PASSWD
cd $SERVER_FOLDER
mput -r *
close
bye
END_SCRIPT
echo "Upload complete"
exit 0
Output:
directory: not a plain file.
Permission denied.
Passive mode refused.
OS: Ubuntu 16.04 Panel: VestaCP
But when i upload files via filezilla, uploads is complete.
If anybody has a script which uploads files and folders via ftp, please, show me for example.

How to run multi commands in one sh file?

I have a mac os and
my question is about 'How to run multi commands in one sh file?', like this :
#!/bin/bash
ftp
open domain.com
user
pass
cd /public_html/test_folder
lcd /Users/mac/downloads
mput file
a
This commands for :
open ftp
connect to my website
enter user name
enter password
cd << for open folder in my website
lcd << open folder in my computer
mput << upload file from my computer
a << for question in ftp for file type or something like this
I add && in end each line but no work he start and stop in command line number 2
I'm sorry for my bad language :(
Use lftp, very good in ftp scripting, when you require reconnect+continue file transfer, ssh/scp transfer, etc.
It should be similar to this:
#!/bin/bash
## note: mput: -c (retry+continue); run: lftp -c 'help mput' to see help
lftp -c 'mput -c -O ftp://name:passd#server.com/path/ file1.txt file2.txt'
Alternatively, you can write lftp scripts, example (note: mirror -R = upload):
#!/usr/bin/lftp -f
open ftp://ftp.server.com
user name passwd
cd /remote/path
lcd /local/path
mirror -R folder

FTP files in different folders using shell script

I'm trying for an ftp script, that sends files in different folders within the same connection, but no luck with below script.
#!/bin/bash
HOST_NAME=host.server
username= user_name
passwd= password
remote = /path_to_remote/folder
local = /path_to_local/folder
folder=$1
pwd
ftp -in <<EOF
open $HOST_NAME
user $username $passwd
cd local/
lcd remote/
put a_filename_<timestamp>.txt
mkdir $remote/$folder
cd $remote/$folder
lcd $local/$folder
put b_filename.txt
close
bye
Adding to this, at run-time, is it possible to send only the latest files created in the last 10 minutes?
Try this:
#!/bin/bash
HOST_NAME=host.server
username=user_name
passwd=password
remote=/path_to_remote/folder
local=/path_to_local/folder
folder="$1"
pwd
ftp -in <<EOF
open "$HOST_NAME"
user "$username" "$passwd"
cd local/
lcd remote/
put a_filename_<timestamp>.txt
mkdir "$remote/$folder"
cd "$remote/$folder"
lcd "$local/$folder"
put b_filename.txt
close
bye
EOF
Notes:
The shell doesn't allow spaces next to =.
Quote variables.
OP code lacked closing EOF.
I've left the <timestamp> alone, that'd be a different Q.

Download files from specific folder in AIX box

I have an AIX box. I wanted to connect to remote FTP server and download a specified folder "abc".
I have created a script; but it isn't working.
Here is my Code:
#!/bin/sh HOST='ftp.abc.xysz.net' USER='ftp' PASSWD='password' FILE='ababababababababababababab.abab';
ftp $HOST user $USER $PASSWD mget $FILE
quit END_SCRIPT
exit 0
Here is the error I receive when I execute Script..
Anyone has any idea to download the files from remote FTP server. Is there any single command available
Your script doesn't look properly formatted... it would be something like this:
#!/bin/sh
HOST='10.129.151.41'
USER='technicolor'
PASSWD='blueray'
FILE='ababababababababababababab.abab'
ftp -n <<END_SCRIPT
open $HOST
user $USER $PASSWD
get $FILE
quit
END_SCRIPT

moving remote files inside ftp in shell script

I want to ftp file to my remote server and then move those files into another directory in the remote server
The ftp happens correctly but the movement is throwing an error like
550 RNFR command failed.
Can you please help?
My script is
#!/bin/sh
echo "Enter the version of the xml (eg:- v17.25)"
read version
HOST_FIRST='un01'
HOST_LAST='01'
USER='someuser'
PASSWD='somepassword'
HOST="$HOST_FIRST$FILE$HOST_LAST"
ftp -n $HOST <<-END_SCRIPT
quote USER $USER
quote PASS $PASSWD
cd /tmp
put myfile.xml
rename myfile.xml /tmp/test_ftp
quit
END_SCRIPT
exit 0
You have put myfile.xml to the tmp dir, why not just
edit
Change your script from
rename myfile.xml /tmp/test_ftp
TO
rename myfile.xml test_ftp
You have already put the file in the /tmp directory, which you have already done a cd /tmp .
That should work.
You can't specify a path in an ftp rename command and expect it to be moved as well.
And sorry, not what you want to here, but there is no move command in ftp. It is that way for security.
IHTH.

Resources