Problem on throwing sftp in nohup


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Problem on throwing sftp in nohup
# 1  
Old 01-24-2011
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???
# 2  
Old 01-24-2011
Describe a bit more in detail what you want to do, thanks.
# 3  
Old 01-24-2011
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:
Mod Comment 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 02:18 AM.. Reason: code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Nohup problem

Hi I need to execute about 1000 scp commands sequential , so I made "scp.sh" - like this scp - rp ... scp - rp ... ............ scp - rp ... then I run nohup sh scp.sh &The problem is: nohup process stopped when I closed session, or when the session expired,... Something wrong :(:(:( ... (4 Replies)
Discussion started by: bobochacha29
4 Replies

2. Shell Programming and Scripting

Saving nohup output to a file other than nohup.out

Shell : bash OS : Oracle Linux 6.4 I want to save the ouput of a nohup command to file other than nohup.out . Below are my 3 attempts. For both Attempt1 and Attempt2 , the redirection logs the output correctly to the output file. But I get the error "ignoring input and redirecting stderr to... (7 Replies)
Discussion started by: kraljic
7 Replies

3. Ubuntu

nohup problem

Hi All I am struggling to get a process to run in the background on a Ubuntu Linux machine. I run: - /home/brad > /usr/bin/nohup sudo /home/brad/spideroak/jsystem/runner/runAgent < /dev/null & 5611 /home/brad > /usr/bin/nohup: appending output to `nohup.out' + Stopped (SIGTTOU) ... (9 Replies)
Discussion started by: steadyonabix
9 Replies

4. Shell Programming and Scripting

Problem with nohup use in scripting

I am trying to execute following code: alarm_file_array="test1.alarms test2.alarms test3.alarms test4.alarms" for file in ${alarm_file_array} do nohup tail -f $file |awk 'NR>10' >> output.alarms 2>/dev/null & done Whenever it tries to execute nohup command it hangs because of the... (3 Replies)
Discussion started by: bhallarandeep
3 Replies

5. Shell Programming and Scripting

Problem regarding nohup.out

There is a daemon which is constantly writing to this particular nohup.out file.This daemon can't be stopped. But the large size of this file is hampering the directory space.I want to write a script which will wait for 48 hours and then delete the contents of the file ( nohup.out ), but not the... (1 Reply)
Discussion started by: Gourav
1 Replies

6. Shell Programming and Scripting

Problem with nohup

Hello I am running this script inst.sh #!/bin/ksh sqlplus -s username/password @temp.sql ----Here is my temp.sql set serveroutput on select instance_name from V$instance; exit When i run the script inst.sh on the command prompt...it runs fine...but when i run it using... (5 Replies)
Discussion started by: njafri
5 Replies

7. Shell Programming and Scripting

problem with exit while using nohup

Hi, I am kinda confused with this, am not sure what is happening i have a script say test.sh ---------- cat myfile | while read line do exit 2 done echo "out of loop" ----------- as it is evident, the exit should cause the script to terminate ,hence producing no output for the... (1 Reply)
Discussion started by: sumirmehta
1 Replies

8. UNIX for Dummies Questions & Answers

Problem with nohup command

Hello folks, I have got a script which telnets to different boxes and runs a certain script with 3 run time args. The line from the script which does it is: (sleep 1; echo $USERID ; sleep 1; echo $PASSWD ; sleep 1 ; echo y ; sleep 1 ; echo "\r" ; sleep 1 ; echo "cd $FILEPATH" ; sleep 1 ; sleep 1... (1 Reply)
Discussion started by: Rajat
1 Replies

9. Solaris

problem with nohup

While executing a ksh file with a input parameter in background like the following bash-2.03$nohup fil.ksh 4 & the nohup session is stopped. The same ksh file while executed like bash-2.03$fil.ksh 4 works fine. I am trying the above in Solaris 5.8 in bash shell. Please let me... (2 Replies)
Discussion started by: kkna
2 Replies

10. Shell Programming and Scripting

Problem executing nohup

I am trying to submit background jobs using the nohup command on a client system where my session is running under a "master shell" (BASH). If I try to nohup the actual job (ie: nohup MYJOB.BAT > MYJOB.LOG 2>&1 &) the command will fail with a return code of 126 and a "permission denied" message.... (0 Replies)
Discussion started by: christyw
0 Replies
Login or Register to Ask a Question