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


 
Thread Tools Search this Thread
Operating Systems Solaris how scp a file to server with space in the directory name
# 1  
Old 01-12-2012
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 Solaris 8, 9 & 10. The server I’ve been testing on is Solaris 8.

The script needs to be run as user smuser out of cron:
Code:
  15 1 * * * /apps/smuser/bin/rotate-smlogs 1>/apps/siteminder/backup_logs/rotate-smlogs.log 2>&1

rotate-smlogs (ksh)

# Call the rsync-smlogs script to perform the transfer
Code:
/apps/smuser/bin/rsync-smlogs $YMON

$YMON resolves to 2012-01

The part of the script in rsync-smlogs that has an issue
I added the echo for debugging
Code:
     echo "sending $backupdir/smaccess*.log nic_sshd@20.2.18.31:'CA\ SITEMINDER_${HENT[0]}/'"
     # Send to Audit Log Assurance (20.2.18.31) to \CA SITEMINDER_<IPADDR>\
     /usr/local/bin/scp -i $HOME/.ssh/id_logs \
            $backupdir/smaccess*.log \
            nic_sshd@20.2.18.31:CA\ SITEMINDER_${HENT[0]}/

This is what I see in the log file
Code:
  scp: CA: Not a directory.

I changed the script to use
Code:
nic_sshd@20.2.18.31:'CA\ SITEMINDER_${HENT[0]}/'

This worked when I did it manually:
Code:
  su - smuser (this is a ksh)
  /apps/smuser/bin/rsync-smlogs 2012-01
   
  smaccess.log                                                           100%   89MB 842.0KB/s   01:48

So I updated all the other servers with the updated script, however, it seems it only worked once. If I run the script or do it manually, it’s failing again:
Code:
scp: CA\: Not a directory.

Someone from the monitoring team has access to the Windows server. He says the envision software doesn’t allow him to change the directory name to remove the space in the name. He also says he can scp files to a directory name with a space in it from another Windows PC using putty or from a Linux server.

On PC, send part of script
Code:
  W:\pscp.exe E:\lsdata-stat.txt nic_sshd@20.2.18.31:"CA SITEMINDER TEST"

On Linux, send part of script
Code:
scp file_name nic_sshd@20.2.18.31:"CA SITEMINDER TEST"
   
ssh polus2
vi /apps/smuser/bin/rsync-smlogs
nic_sshd@20.2.18.31:'CA\ SITEMINDER_${HENT[0]}/'
   
su - smuser
   
vi rsync-smlogs
echo "sending $backupdir/smaccess*.log nic_sshd@20.2.18.31:'CA\ SITEMINDER_${HENT[0]}/'"
   
$ /apps/smuser/bin/rsync-smlogs 2012-01
sending /apps/siteminder/backup_logs/smaccess*.log nic_sshd@20.2.18.31:'CA\ SITEMINDER_20.137.241.133/'
   
scp: CA\: Not a directory.

try using bash like from a Linux server
Code:
$ bash
bash-2.03$
   
scp -i /apps/smuser/.ssh/id_logs /apps/siteminder/backup_logs/smaccess*.log \
nic_sshd@20.2.18.31:"CA SITEMINDER_20.137.241.133/"
   
scp: CA: Not a directory.

Does anyone have an insight into how to resolve this problem?

Moderator's Comments:
Mod Comment Please use code tags, see PM, thanks.

Last edited by zaxxon; 01-12-2012 at 04:28 PM.. Reason: code tags, see PM
# 2  
Old 01-12-2012
Escape the space.

Code:
 scp localfile host:"dir\ with\ spaces"

# 3  
Old 01-12-2012
Thanks for the reply, however, I am already escaping the space with a \. The last tests at the end of my post were to try what is alleged to have worked on a Linux box.

Code:
su - smuser
scp -i /apps/smuser/.ssh/id_logs /apps/siteminder/backup_logs/smaccess*.log nic_sshd@20.2.18.31:'CA\ SITEMINDER_20.137.241.133/'
scp: CA\: Not a directory.

# 4  
Old 01-12-2012
Technically I used double quotes, but the result ought to be the same in this case.

It certainly works for me, so I'm beginning to suspect the problem isn't the linux client but the remote ssh server, where that sort of expansion actually happens.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need some help regarding file transfer between server (sftp/scp)

Hi All, Need some help regarding file transfer between server. Suppose we have system-A and system-B. To transfer file from system-A to system-B we usually share the public keys of system-A to system-B and do scp/sftp to transfer a file. Is it possible that public key of system-B can be... (3 Replies)
Discussion started by: abhi_123
3 Replies

2. Shell Programming and Scripting

How to get the latest file from a directory in Server B to Server A?

ssh user@hostnameB cd /home/oracle latest_file_target=$(ls -trp -I "*.pd.Sat" -I "*.pd.Lag" -R | grep -v "/.pd" | tail -1) scp -r $latest_file_target user@hostnameA:$TARGET_DIR/ exit (1 Reply)
Discussion started by: ahmed.vaghar
1 Replies

3. Shell Programming and Scripting

I want to scp file from one server to another, both server have different user name and

i want to scp file from one server to another. both server have different user name and it needs to give password to transfer file.how can we mention password in the script itself so that we need not mention password while running the script. Say from servers cpli with user abc and file path /opt... (7 Replies)
Discussion started by: Moon1234
7 Replies

4. Shell Programming and Scripting

How to scp File from root user in one server to say crt user in another server and avoid password?

Can someone help in writing some script through which I can transfer file (scp) from root user in abc server to crt user in hfg server and can give the crt user password in script itself so that it doesn't prompt me every time for password (4 Replies)
Discussion started by: Moon1234
4 Replies

5. UNIX for Dummies Questions & Answers

Use screen command in AIX to scp file to other server

Hello, Please assist me in using screen command in AIX to scp file to other server Best regards, Vishal (10 Replies)
Discussion started by: Vishal_dba
10 Replies

6. UNIX for Dummies Questions & Answers

scp to get a file from windows desktop to UNIX server

Hi, I want to use scp to upload file to my unix server. i am using this: scp D:\testr.txt unixuser@unixhost:/path it returns an error: ssh: D: host/servname not known i am not sure how to tell path of my D drive in the command and how will command understand it has to pick from my... (5 Replies)
Discussion started by: Kohli
5 Replies

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

8. Shell Programming and Scripting

Script to check for the newest file mutiple times a day and SCP it to another server.

Hi, I need a sample of a script that will check a specific directory multiple times throughout the day, and scp the newest file to another server. Example: current file is misc_file.txt_02272011 (the last part is the date), once that has been secure copied, another one may come in later the... (1 Reply)
Discussion started by: richasmi
1 Replies

9. Shell Programming and Scripting

scp file to another server without asking for password

hi I tried reading some of the threads w.r.t scp/sftp file to another server in the same network without asking for password while copying files.....but couldnot succeed. i have generated the public key for the system using "ssh-keygen -t " and kept it in the .ssh/authorized_keys file. ... (8 Replies)
Discussion started by: aemunathan
8 Replies

10. UNIX for Dummies Questions & Answers

File Missing When Grabbing Files from SFTP Server using SCP Command

Hi, I have this problem where sometimes my files would go missing when I schedule my crontab to run the SCP command to get file from the SFTP server. My crontab will run the scripts at an interval of 3 minutes (between the two scripts) The following is the setting in my crontab. ... (1 Reply)
Discussion started by: gingervitus
1 Replies
Login or Register to Ask a Question