scp from variable date directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting scp from variable date directory
# 1  
Old 05-08-2014
Network scp from variable date directory

I am trying the mentioned script as
Code:
#!/usr/bin/expect -f

# connect via scp
spawn scp root@10.71.15.34:/apps/log/ui/(date +\%Y\%m\%d)/BATCH*.log /root/BATCH_VSAT_MME01.log
#######################
expect {
-re ".*es.*o.*" {
exp_send "yes\r"
exp_continue
}
-re ".*sword.*" {
exp_send "qweasdzxc123\r"
}
}
interact

Here I am using variable date folder as per current date But while executing this script I am getting error
Code:
spawn scp root@10.71.15.34:/apps/log/ui/(date +%Y%m%d)/BATCH*.log /root/BATCH_VSAT_MME01.log
/root/BATCH_VSAT_MME01.log: No such file or directory
spawn_id: spawn id exp6 not open
    while executing
"interact"
    (file "./yogesh.sh" line 14)

Need your expert help for resolution of this and also need help for executing same type of script for IPv6 Ip address.

Last edited by Franklin52; 05-08-2014 at 10:08 AM.. Reason: Please use code tags
# 2  
Old 05-20-2014
Security is better with trusted PPK keys than passwords in scripts.

Stick the command 'echo' before 'scp' for debugging your bad created command.
# 3  
Old 05-20-2014
Quote:
Originally Posted by DGPickett
Security is better with trusted PPK keys than passwords in scripts.

Stick the command 'echo' before 'scp' for debugging your bad created command.
That was my first thought too. If you are already using "scp" then I'd recommend setting up keys that allow you to "scp" without needing a password. Then your scripts get much, much simpler.
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 replace a parameter(variable) date value inside a text files daily with current date?

Hello All, we what we call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to... (1 Reply)
Discussion started by: pradeepp
1 Replies

2. Shell Programming and Scripting

List files with date, create directory, move to the created directory

Hi all, i have a folder, with tons of files containing as following, on /my/folder/jobs/ some_name_2016-01-17-22-38-58_some name_0_0.zip.done some_name_2016-01-17-22-40-30_some name_0_0.zip.done some_name_2016-01-17-22-48-50_some name_0_0.zip.done and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies

3. Shell Programming and Scripting

Convert a date stored in a variable to epoch date

I am not able to pass date stored in a variable as an argument to date command. I get current date value for from_date and to_date #!/usr/bin/ksh set -x for s in server ; do ssh -T $s <<-EOF from_date="12-Jan-2015 12:02:09" to_date="24-Jan-2015 13:02:09" echo \$from_date echo... (7 Replies)
Discussion started by: raj48
7 Replies

4. Shell Programming and Scripting

To get the files in a directory for the given date (User entered date)

Need a ksh script to get the files that were created or modified in a directory on a particular date entered by the user. For example if a directory contains files as below : > ll total 41 -rw-rw-r-- 1 psn psn 199 Aug 23 07:06 psn_roll.sh -rw-rw-r-- 1 psn psn ... (10 Replies)
Discussion started by: ramprabhum
10 Replies

5. UNIX for Dummies Questions & Answers

SCP error: No such file or directory

Hi, I am trying to do scp using the following script: #!/usr/local/bin/bash BUILDDATE=20120220 for line in `cat arch_host_plat_src_dest` do src=`echo $line | cut -d: -f4` dest=`echo $line | cut -d: -f5` echo scp -p /builds/${BUILDDATE}/Integration/$src ... (1 Reply)
Discussion started by: Technext
1 Replies

6. UNIX for Dummies Questions & Answers

directory copy with scp

I need to copy all files and directories with scp, but seems I am missing something? /usr/bin/scp -p /custscripts/* rmprod2:/custscripts doesn't copy directories and files under them. Please advise. (1 Reply)
Discussion started by: Daniel Gate
1 Replies

7. Solaris

how scp a file to server with space in the directory name

Hello forum, I’m trying to get someone else’s log rotation & sync script working. The ksh script is sending daily compressed log files to a Windows RSA envision server. The name of the directory is “CA SITEMINDER_<IP address of the sending server>”. The servers we are sending from are a mix of... (3 Replies)
Discussion started by: TKD
3 Replies

8. UNIX for Dummies Questions & Answers

Scp from local to external directory

Hi, I am trying to copy a whole directory from my home /RUN1 to the external directory jorgensen@hal.oerc.ox.ac.uk:/home/compchem/jorgensen/simulations The command I have used is: scp -r jorgensen@hal.oerc.ox.ac.uk:/home/compchem/jorgensen/simulations The error message I get is: ... (5 Replies)
Discussion started by: chrisjorg
5 Replies

9. Shell Programming and Scripting

Creating date directory and moving files into that directory

I have list of files named file_username_051208_025233.log. Here 051208 is the date and 025233 is the time.I have to run thousands of files daily.I want to put all the files depending on the date of running into a date directory.Suppose if we run files today they should put into 05:Dec:08... (3 Replies)
Discussion started by: ravi030
3 Replies

10. Solaris

scp prompt when home directory is 777

Morning all, I was running some deployment scripts on Friday night that kept failing because it prompted for a password for a user I was already sudo'd in as when trying to scp a file onto itself. e.g. on server 51.123.123.123 as sudo dlam typing: scp testfile dlam@51.123.123.123:/tmp ... (5 Replies)
Discussion started by: dlam
5 Replies
Login or Register to Ask a Question