Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Search Forums:



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-24-2011
Registered User
 

Join Date: Jan 2011
Location: Rome
Posts: 28
Thanks: 0
Thanked 3 Times in 3 Posts
Problem on throwing sftp in nohup

Hi, but it is possible to effect a sftp in???


thanks thousand

Germanico

---------- Post updated at 07:01 AM ---------- Previous update was at 05:51 AM ----------

Hi, but it is possible to effect a sftp in nohup mode???
Sponsored Links
    #2  
Old 01-24-2011
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
code tag tagger
 

Join Date: Sep 2007
Location: Germany
Posts: 5,201
Thanks: 48
Thanked 285 Times in 271 Posts
Describe a bit more in detail what you want to do, thanks.
Sponsored Links
    #3  
Old 01-24-2011
Registered User
 

Join Date: Jan 2011
Location: Rome
Posts: 28
Thanks: 0
Thanked 3 Times in 3 Posts
This belongs to my program,

launched in formality forground: OK

but launched in formality background: suspended

do you have an idea?

the script SFTP_FOR_C1.exp recalled to the inside it is this:

Code:
#!/usr/local/bin/expect -f #<---insert here your expect program location
# procedure to attempt connecting; result 0 if OK, 1 elsewhere
proc connect {passw} {
 expect {
  -re ".*Are.*.*yes.*no.*" {
   send "yes\r"
   exp_continue
  }
  -re ".*PASSWORD.*" { 
   send "$passw\r"
   expect {
    "sftp*" {
     return 0
    }
   }
  }
  -re ".*password.*" { 
   send "$passw\r"
   expect {
    "sftp*" {
     return 0
    }
   }
  }
  -re ".*Password.*" { 
   send "$passw\r"
   expect {
    "sftp*" {
     return 0
    }
   }
  }
 }
 # timed out
 return 1
}
# read the input parameters
set user [lindex $argv 0]
set passw [lindex $argv 1]
set host [lindex $argv 2]
set remotepath [lindex $argv 3]
set localpath [lindex $argv 4]
set file1 [lindex $argv 5]
set file2 [lindex $argv 6]
# check if all were provided
if { $user == "" || $passw == "" || $host == "" || $remotepath == "" || $localpath == "" || $file1 == "" }  {
 puts "Usage: <user> <passw> <host> <remote path> <local path> <file to send> [<file to send>]\n"
 exit 1
}
 
# sftp to specified host and send the files
spawn /usr/local/bin/sftp $user@$host
set rez [connect $passw]
if { $rez == 0 } {
 send "lcd $localpath\r"
 send "cd $remotepath\r"
 set timeout -1
 send "put $file1\r"
 if { $file2 != "" } {
  send "put $file2\r"
 }
 send "quit\r"
 expect eof
 exit 0
}
puts "\nError connecting to server: $host, user: $user and password: $passw!\n"
exit 2

 
 
 
##### Constants
# recupero properties da file
. ../cfg/init.cfg
function CopyC1
{
for dir in ${dir_list}
do
LPATH=${PARTIALPATH}${dir}
cd ${LPATH}
gunzip *.gz
PRODNUM=`ls -1 | grep "\.cdr$" | wc -l | awk '{print $1}'`
writeInfo "Numero dei file pronti per essere inviati: ${PRODNUM}"
STARTTIME=$Now
writeInfo "Connessione SFTP e trasferimento files start: $STARTTIME..."
writeInfo "=========================================================================================="
SFTPLOG=`${EXEPATH}SFTP_FOR_C1.exp ${USER} ${PASS} ${HOST} ${RPATH} ${LPATH} '*.cdr'`
writeInfo "USER : ${USER}"
writeInfo "PSWD : ${PASS}"
writeInfo "HOST : ${HOST}"
writeInfo "RPATH: ${RPATH}"
writeInfo "LPATH: ${LPATH}"
SFTPNUM=`echo "${SFTPLOG}" | grep "100%" | wc -l | awk '{print $1}'`
RepDate=`date +%y%m%d-%H%M%S`
echo "${STARTTIME}|${RepDate}|SFTP_START|SFTP_END|${PRODNUM}|${SFTPNUM}" >> ${SPLFILE}
if [ ${SFTPNUM} -ne ${PRODNUM} ]
then
   writeError "ERRORE: numero file trasferiti (${SFTPNUM}) diverso da quello atteso (${PRODNUM})!"
Close 2
fi
writeInfo "Numero file trasferiti: ${SFTPNUM}"
writeInfo "Compressione file"
gzip *.*
VARSLEEP=`grep -i SLEEP ${FILE_CFG} | cut -f2 -d =`
writeInfo "Tempo di sleep: ${VARSLEEP}"
sleep ${VARSLEEP}
writeInfo "=========================================================================================="

done
Close 0
}

Moderator's Comments:
Please use [code] and [/code] tags when posting code, data or logs etc. to preserve formatting and enhance readability, thanks.

Last edited by zaxxon; 01-26-2011 at 01:18 AM.. Reason: code tags
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem regarding nohup.out Gourav Shell Programming and Scripting 1 12-15-2009 06:37 AM
Problem with nohup njafri Shell Programming and Scripting 5 03-09-2009 08:54 PM
problem with exit while using nohup sumirmehta Shell Programming and Scripting 1 01-21-2009 09:39 PM
problem with nohup kkna Solaris 2 06-25-2008 04:30 AM
Problem executing nohup christyw Shell Programming and Scripting 0 12-01-2005 02:17 PM



All times are GMT -4. The time now is 03:03 AM.