Need to execute a command on a path with a space in it...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to execute a command on a path with a space in it...
# 1  
Old 06-04-2009
Need to execute a command on a path with a space in it...

Hello,

I need to execute the following command in a script:

/usr/bin/ssh 205.21.1.1 vmware-cmd -v /home/virtual machines//Machine.vmx"createsnapshot Weekly_Backup >/dev/null 2>&1

The problem is that there is a space between virtual and machines and when I run the script I get no such directory /home/virtual....

I need to escape the space somehow so that the script knows to look for the directory "virtual machines" How do I do this?
# 2  
Old 06-04-2009
Set the full filename inside single ticks
Code:
/usr/bin/ssh 205.21.1.1 vmware-cmd -v /home/virtual machines//Machine.vmx 'createsnapshot Weekly_Backup' >/dev/null 2>&1

You had a quote in there so I can't really know where the tics belong.
# 3  
Old 06-04-2009
Quote:
Originally Posted by mojoman
Hello,

I need to execute the following command in a script:

/usr/bin/ssh 205.21.1.1 vmware-cmd -v /home/virtual machines//Machine.vmx"createsnapshot Weekly_Backup >/dev/null 2>&1

That is not a complete command; you have an unclosed quote.
Is this what you want:

Code:
/usr/bin/ssh 205.21.1.1 vmware-cmd -v "/home/virtual machines//Machine.vmx" createsnapshot Weekly_Backup >/dev/null 2>&1

Quote:
The problem is that there is a space between virtual and machines and when I run the script I get no such directory /home/virtual....

I need to escape the space somehow so that the script knows to look for the directory "virtual machines" How do I do this?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need assistance to define path on a script which cron will execute

I have written a script to execute some sql statement via executable file. It is working fine via command line, however when I schedule it in cron. The executable file is looking for library file in its root directory. Wonder where does cron run the script from, and can we get the script... (4 Replies)
Discussion started by: jaapar
4 Replies

2. UNIX for Advanced & Expert Users

Command to see the logical volume path, device mapper path and its corresponding dm device path

Currently I am using this laborious command lvdisplay | awk '/LV Path/ {p=$3} /LV Name/ {n=$3} /VG Name/ {v=$3} /Block device/ {d=$3; sub(".*:", "/dev/dm-", d); printf "%s\t%s\t%s\n", p, "/dev/mapper/"v"-"n, d}' Would like to know if there is any shorter method to get this mapping of... (2 Replies)
Discussion started by: royalibrahim
2 Replies

3. UNIX for Beginners Questions & Answers

Space in PATH variable

Hi All, I did a review of some threads to see if someone had come across this problem. My system is an oracle virtual box solaris 10 installed on a windows 10 system. Right now I am learning scripting and am just playing with the env variables. I am trying to update the PATH to... (9 Replies)
Discussion started by: bdby
9 Replies

4. UNIX for Dummies Questions & Answers

Find command fails when a space is in the directory path variable

I have a script like this running under OS X 10.8. The problem arises when the find command encounters a space in the path name. I need the "dir" variable as I'll be extending the script to more general use. #!/bin/bash CFS=$IFS IFS=$(echo) set dir = "/Users/apta/Library/Mail\... (3 Replies)
Discussion started by: apta
3 Replies

5. Shell Programming and Scripting

Setting path variable with a space.

Hi I am using MKS Toolkit c shell. I am trying to set a path variable something like c:/Program Files/blah/blah so set path=(c:/Program Files/blah/blah) this, however, does not work as it splits this thing up into 'c:/Program' and 'Files/blah/blah'. Does anyone have any ideas on... (9 Replies)
Discussion started by: vas28r13
9 Replies

6. UNIX for Dummies Questions & Answers

Highlight directories in path with execute permission for others

Hi all, I'm trying to make a script that takes at the most one argument and lists all directories in the path in a special format: User Group Other Filename rwx r-- r-x \ rwx r-x r-- home This is my code as it is... (1 Reply)
Discussion started by: Trinimini
1 Replies

7. Shell Programming and Scripting

sftp how to deal with space in path to dir?

OK I am trying to use something similar to this: #!/bin/sh echo "OK, starting now..." sftp -b /dev/fd/0 user@remotehost <<EOF cd pub ascii put filename.txt bye EOF only difference is the dir I need to cd to has a space in it like this /Import/Server/Prospect File ,... (3 Replies)
Discussion started by: NewSolarisAdmin
3 Replies

8. Shell Programming and Scripting

Problems with Space at path

Hi everyone, I create script for seaching count of differrent file types at my FS. My script: #! /bin/sh #OLD_IFS=$IFS #export IFS=$(echo "\n\t ") echo "Wait a minute... Seaching is performed" d=0;b=0;c=0;p=0;s=0;l=0;f=0 non=0 for fl in $(find /opt/google/picasa/3.0/wine/drive_c... (8 Replies)
Discussion started by: babi4
8 Replies

9. Shell Programming and Scripting

File path with space as external input to the program

Hello I am getting error when the file (Folder or Application) path having space is given as external input to the shell program. It works fine for the files which has no spaces in the file name Thans, (5 Replies)
Discussion started by: keshav.murthy@r
5 Replies

10. UNIX for Advanced & Expert Users

set path so all new users can execute the command in /bin/mycommands

I want to add a default path /bin/mycommands along with others to be loaded as default path for all new accounts created on my system . With out the new accounts not having to change thie manually to /bin/mycommands.Do I change the /etc/profile ? is there any better way? Please throw some... (2 Replies)
Discussion started by: sravusa
2 Replies
Login or Register to Ask a Question