Register
It is currently Wed Apr 16, 2014 4:38 am

Basic Test Script


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Sun Feb 27, 2011 9:14 pm   

Joined: Mon May 31, 2010 7:40 pm
Posts: 25
First post here and I belive this is where the very basic questions go, so.

I have a script where I check if a directory exists. If not, then it creates the directory, changes into the directory and initiates an sftp session to download files.

My only concern with it is on the last read (read answer) it actually displays the option I chose which is no big deal and thinking about this, I really don't care that it does this.

Well, I am wondering if someone can take a look at it and tell me how I can improve it or make suggestions?

Code:
#!/bin/bash

HOME=/home/user

sftp () {
    /usr/bin/sftp user@sftp.server.com
}

makedir () {
    mkdir $HOME/$number
}

echo -n "enter the last four digits of the case number "

read number

if [ ! -d $HOME/$number ]; then
    echo "directory does not exist, now creating directory..."
makedir;
cd "$HOME/$number"
sftp;
    else
    echo "directory exists..."
    echo "do you want to initiate sftp y/n"
        read answer
    if  [[ $answer == [yY] ]];then
cd "$HOME/$number"
sftp;
    else
        echo "goodbye..."
exit 1
  fi
fi


I just noticed that when testing with FTP the script works as I am prompt to enter my credentials. However, whilst using sftp it just loops and I am somewhat lost as to why it does this?

I determined it sitting in a loop by running bash - x script.sh

and all I saw was the lines sftp sftp.server.com over and over again.

Will continue troubleshooting this issue.

I corrected the issue above by providing the full path to sftp.
Thank you!


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP