This question already has answers here:
How to create batch file in Windows using "start" with a path and command with spaces
(7 answers)
Closed 2 years ago.
So normally I have several *.bat files to automate some things in my computer.
But I'm kinda stuck in this call...
cd "C:\Users\user\AppData\Local\Programs\program2Execute"
start program has spaces.exe
I don't get the app executed, instead I get a cmd window with the cd command result, nothing else. I tried to quote "program has spaces.exe" but it doesn't get executed I get the window duplicated instead.
Apologize if this is kinda dumb to ask, but I have spent quite time looking for the answer.
Thanks in advance.
If you use the start command:
start "" "a program with spaces.exe"
start will use the first double quoted string as the title and the 2nd as the command.
Or don't use start:
"a program with spaces.exe"
Related
This question already has answers here:
How can I debug a Bash script? [closed]
(12 answers)
Closed 2 years ago.
I'm not sure I address this problem correctly, but I've search and search over the net and found nothing, yet.
I'm writing a bash script and I want to see what the script is really doing when being executed, like a log of all the commands, one by one, what are executed - this way, I'll be able to see why my script is falling.
Note : I've post similar question in the past, someone told me I run my bash script with sh -xe script.sh but it doesn't give me enough information to debug properly.
Please advise. Thanks!
Adding set -x at the beginning of the script displays, in the terminal, all the commands sent by the script as the terminal received it. It was exactly what I needed and it working perfectly.
This question already has answers here:
Bash script to cd to directory with spaces in pathname
(14 answers)
Closed 2 years ago.
I am trying to navigate the bash command line to a subdirectory of my /projects directory, and I keep getting 'No such file or directory'.
The ls command clearly shows the directory in existence.
What am I missing?
Note: I am trying to navigate to the directory to run npm tests, if that context matters :)
This may be due to the space in your directory name.
You can either rename it for easier access or just start writing the name and use autocompletion (with tab) to let the system write it properly for you.
If the above solutions still don't work, try to escape the space with a backslash (Content\ Creator) to see what happens.
You may try to put quotation marks around 'Content Creator' like that.
When you try to navigate to any directory, it is better you always use quotation marks even there is no space character. Because it could have similarity with a command. To prevent any trouble.
This question already has answers here:
How do I get the directory where a Bash script is located from within the script itself?
(74 answers)
Closed 5 years ago.
If I have a bash script in my home directory and call for it to execute from my Desktop, is it possible for the script to know the request to execute came from the Desktop? I've figured out how to get the path of where the script file is, but I want to know where the request came from.
Thanks!
Try this:
srcdir=$(pwd)
which gets you the current directory. That is, where you are calling your script from, which should be Desktop something in your example.
As duly discussed in the comments, this alternative is pretty good too:
srcdir=$PWD
This question already has answers here:
bash script order of execution
(2 answers)
Closed 7 years ago.
I was just wondering, in a bash script, if I have a command on one line to say rsync a large file (~10GB) then the next command on the next line is meant to rename then move that same file, will the script know to wait for the rsync to complete before attempting the rename and move?
Is there a flag or something I can put on each line to make it wait before executing the next command?
Sorry if this seems like a total noob question, but alas I am a noob!
Thanks in advance for any info!
All commands are executed in sequence, so, a command will wait for the previous command to complete. Only when you add a & to the end of a command will it run in the background, and thus not wait for completion before executing the next.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How do I escape ampersands in batch files?
I am attempting the following, in Windows:
$ start http://code.google.com/p/mulder/downloads/detail?name=MPUI.2011-06-09.Full-Package.exe&can=2&q=MPlayer&sort=-uploaded
Unfortunately, it seems that no amount of quoting or escaping actually pulls up the full URL in a browser, only partial (up through can=2) or what not. How can I do it?
You can use ^ to escape & in teh command line like this:
$ start http://code.google.com/p/mulder/downloads/detail?name=MPUI.2011-06-09.Full-Package.exe^&can=26^&q=MPlayer^&sort=-uploaded
Try this
start "test" "C:\Program Files (x86)\Internet Explorer\iexplore.exe" "http://code.google.com/p/mulder/downloads/detail?name=MPUI.2011-06-09.Full-Package.exe&can=2&q=MPlayer&sort=-uploaded"
It worked for me in Windows 7. (all on one line).
I hope this helps.