Help with Zip and FTP Shell Script


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Help with Zip and FTP Shell Script
# 1  
Old 09-27-2019
Help with Zip and FTP Shell Script

I am trying to combine zip and ftp upload in one script but for some reason I can't get it to work. It zips properly but does not ftp, seems like it just ignores ftp. Any help would be greatly appreciated. Thanks!


Code:
#!/bin/sh
cd /home/user/test
zip -r test.zip *
FOLDER='/home/user/test'
ZIPS=$(ls $FOLDER)
for F in $zips ; do
  while [ -n '$(lsof | grep $F' ] ; do
  sleep 1
done
ftp -n <<EOF
open 192.103.229.66
user user pass
binary
put test.zip
EOF
done

# 2  
Old 09-30-2019
Probably best not to use ftp, and use either sftp or rync instead (processes which use ssh).

... and then use sshpass.


See for example;

https://www.unix.com/man-page/debian/1/sshpass/
# 3  
Old 09-30-2019
Quote:
Originally Posted by shimabuku
... it just ignores ftp. ...
It doesn't ignore ftp, it just doesn't enter the loop as $zips is unset. *nix is case aware...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to zip csv files having specific pattern in a directory using UNIX shell script?

I have files in a Linux directory . Some of the file is listed below -rw-rw-r--. 1 roots roots 0 Dec 23 02:17 zzz_123_00000_A_1.csv -rw-rw-r--. 1 roots roots 0 Dec 23 02:18 zzz_121_00000_A_2.csv -rw-rw-r--. 1 roots roots 0 Dec 23 02:18 zzz_124_00000_A_3.csv drwxrwxr-x. 2 roots roots 6 Dec 23... (4 Replies)
Discussion started by: Balraj
4 Replies

2. Shell Programming and Scripting

Shell script not able to zip the file using gzip

Hi all, I am calling Temp.sh and it is has simple line $gpath=`which gzip` $gpath $FilePath/My_temp.log if I run this script, logging to server then its works fine. But when I send this script over the SSH it does not work at it. gzip is command is not execute. I am using gzip 1.6... (2 Replies)
Discussion started by: girijajoshi
2 Replies

3. Shell Programming and Scripting

Using Shell Script in place of Perl script to Unzip the zip files.

Hi Expert, We have some shell scripts which Internally uses Perl Script to Unzip the source zip files which comes to inbound directory. So now our requirement is to avoid the dependency on Perl Script and us Shell Script to unzip the files. I have the Perl script with me attached can some one... (3 Replies)
Discussion started by: naveen.dasu
3 Replies

4. Shell Programming and Scripting

Zip and ftp script?

Hello, I am looking for a script to zip some folders and ftp the zip files automatically, is there a script already written somewhere or can someone help me start to write one? thanks a lot (24 Replies)
Discussion started by: bashex
24 Replies

5. Shell Programming and Scripting

Shell Script to zip users cmd history log files

I admit I am terrible with scripting, so when I was asked to store users' command history lines and zip them on monthly basis what I did was to create a file "user_history_Feb" with the following contents: Part A # more user_history_Feb cp -p /var/log/user_history/*history... (6 Replies)
Discussion started by: hedkandi
6 Replies

6. Shell Programming and Scripting

zip the folder and loaded to ftp

Hi , I am working on a script which will do the below things 1) It will checkout from the repository 2) then zip that checkout stuff 3) and put the zip folder to FTP server Here my question is I am able to checkout successfully through this coomand svn co... (2 Replies)
Discussion started by: rohit22hamirpur
2 Replies

7. Shell Programming and Scripting

Zip an excel in a shell script

I am getting an xls file in the dir errorpath. I would like to zip it. Kindly help me on this. The code is as below. sqllst=$errorpath/$run_pgm.${date_stamp}".xls" sqlstatus=$errorpath/$run_pgm"."${date_stamp}".sqlstatus" sqlscript=$binpath"/im_rpt.sql" (2 Replies)
Discussion started by: Nithin
2 Replies

8. Shell Programming and Scripting

To write a shell script which groups files with certain pattern, create a tar and zip

Hi Guru's, I have to write a shell script which groups file names based upon the certain matching string pattern, then creates the Tar file for that particular group of files and then zips the Tar file created for the respective group of files. For example, In the given directory these files... (3 Replies)
Discussion started by: rahu_sg
3 Replies

9. Shell Programming and Scripting

batch shell script to zip individual files in directory - help

help trying to figure out a batch shell script to zip each file in a directory into its own zip file using this code but it does not work tryed this also nothing seems to work , just ends without zipping any files i have over 3000 files i need to zip up individualy ... (7 Replies)
Discussion started by: wingchun22
7 Replies

10. Shell Programming and Scripting

ftp zip files corruption

Hi I have a zip file that I am ftping to another server. After I have ztped the file it is corrupt and cannot be opened by winzip. Can anyone throw any light on to why this would happen. I have no problems with sending the individual files, but when zipped into one file it becomes... (3 Replies)
Discussion started by: colesga
3 Replies
Login or Register to Ask a Question