SFTP / UNZIP script issues


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SFTP / UNZIP script issues
# 1  
Old 11-06-2008
SFTP / UNZIP script issues

Hi everyone,
i'm having a little trouble wih my first shell script ever.

So the point of that script is to:
-Archive Zip files in a directory
-Remove txt files from that directory
-connect through sftp and a rsa key to a remote server
-download a couple of files
-unzip downloaded files

I glanced information here and there and tried to make a script out of it so here's what i've got so far

Quote:
#!/bin/sh
########## CONFIG
INBOX_DIR=/home/data-exchange/inbox
REMOTE_DIR=outgoing/
DATA_DIR_1=users/
DATA_DIR_2=games/

##### ARCHIVE
mv $INBOX_DIR/*.zip $INBOX_DIR/archive
rm $INBOX_DIR/*.txt

##### SFTP GET
sftp myuser@data.myserver.com -P22 <<EOF
cd $REMOTE_DIR
mget $DATA_DIR_1/*.zip $INBOX_DIR
mget $DATA_DIR_2/*.zip $INBOX_DIR
bye
EOF

##### DATA EXTRACT
cd $INBOX_DIR
ls -1 *.zip > filelist
for filename in `cat filelist`
do
unzip $filename
done
rm filelist
So i have a couple problems :
-First of all, i'd like to test the presence of any .txt file before i remove it.Caus' i'd get an error if none exist
-Second, i don't know why, the last part ( #DATA EXTRACT ) is executed before the second part ( #SFTP GET ) , so it doesn't find any files that need decompression ... and my files arent unzipped
-Third, but this is more general, i'd like to make my own output out of this instead of the ugly regular output that all those commands would give me, so any kind of precise link would be greatly appriciated.

Thanks for your time !
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unzip the .zip file without using unzip utility in UNIX

I have .zip file, i want to list all the files archived in the zip file. unzip utility is not working for me in unix. Please help me resolve this issue Thanks ganesh. (3 Replies)
Discussion started by: Ganesh L
3 Replies

2. 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

3. Shell Programming and Scripting

Issues with automating SFTP command

Hi All, I am currently looking at automating the steps that I follow to download log files from putty to desktop. I connect to a client's machine through citrix desktop. I am required to download quite a number of application logs to identfiy the issues in production. Steps that is being... (3 Replies)
Discussion started by: krackjack84
3 Replies

4. 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

5. Shell Programming and Scripting

SFTP issues

Hi All, To transfer the files, from one server to another through SFTP, i am using below code in my script. cur_dt=$1 echo "cd /inbox/" >> SFTP.txt # folder of traget server echo "mput /opt/myfile/inbox/*_${cur_dt}_*.* " >> SFTP.txt # to get files from /opt/myfile for given date and... (1 Reply)
Discussion started by: Amit.Sagpariya
1 Replies

6. Solaris

Issues with automating SFTP

Hi We are trying to set up a non-interactive sftp to one of our clients to be able to transfer files to them. For the setup I logged into server1 as user1 and generated RSA public and private keys id_rsa and id_rsa.pub. Then I did an sftp to server2 as user2 and put the id_rsa.pub in the .ssh... (4 Replies)
Discussion started by: vnparo
4 Replies

7. Shell Programming and Scripting

How to Unzip a .ZIP file in Unix without using unzip cmd..?????

Hi All I have ftped a .ZIP file (zipped using WinZip in Windows) to my Unix server (HP-UX). I don't have unzip cmd available in my curent Unix version Please let me know any cmd in UNIX (other than unzip) using which I can unzip this .ZIP file . Please elaborate on the commands aval and... (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

8. Linux

sftp stalling issues.

Hello, I'm new to linux/unix and presently at my work i have wrote a script that goes out from a unix host connects to a transfer proxy using sftp (username & password) with internal IP address as scp is disabled on the server.. Now my problem is that when i try and get a bigger file sftp will... (1 Reply)
Discussion started by: est
1 Replies

9. HP-UX

How to Unzip a .ZIP file in Unix without using unzip cmd..?????

Hi All I have ftped a .ZIP file (zipped using WinZip in Windows) to my Unix server (HP-UX). I don't have unzip cmd available in my curent Unix version Please let me know any cmd in UNIX (other than unzip) using which I can unzip this .ZIP file . Please elaborate on the commands aval and... (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

10. Shell Programming and Scripting

unzip in script using rsh

Hi I have searched usr/bin and usr/sbin to try to find unzip but I cannot find it. My script is using the ksh #!/usr/bin/ksh but when I rsh to another box it cannot find unzip to unzip to a new archive, but I can unzip files when I am using a telnet session on the box. The error message... (4 Replies)
Discussion started by: speedieB
4 Replies
Login or Register to Ask a Question