Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
How to create a .cmd file in .cmd file and pass variable in it to execute some command.
Is there any way to execute .cmd file in Unix ?
Kindly advice
Thanks,
No, not really
The .cmd files in windows are interpreted by the windows cmd.exe program. If you open one up, you'll find a .cmd file contains text commands to be executed.
In the Unix world the equivalent to command files are shell scripts. These have a .sh extension and are usually interpreted by the bash program.
Read more about shell scripts online
Well maybe...
you can run the cmd.exe program on Linux, Solaris Mac and BSD by using a compatibility layer called Wine However, because of differences between the platforms, you will have to revise you scripts and manually check that things like paths and executable names are still valid.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I test the script in WSL2
Here is my script:
#!/usr/bin/bash
echo "testing..."
printf "testing..."
It work fine if I run like
bash test
source test
. test
But it output nothing if I add the path the script located in to PATH and run
test
Why and how can I fix it?
test is a bash built-in. POSIX systems will also have a test executable.
When you enter a command without specifying a path to the executable, bash will first check if the command is one of its built-in commands before searching for the executable in the PATH. If the command matches the name of one of the bash built-ins, it will run the built-in.
If you still want to run your script without specifying its path, there are two ways to do it:
Recommended: Rename your file, and then run it with its new name (your script file needs to have its executable permission bit(s) set).
Make sure your script has its file permissions set so that it is executable, make sure your PATH is set up so that your test will be found before the system's test, and then run env test to run your script. env will search your PATH to find your test executable, and then it will execute it.
Ultimately, option 2 is not recommended, because it can be brittle to reorder your PATH, and it can be confusing (for you and for others) to have a second test binary on your system.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I am working on a Mac. I am trying to use the fork command to run another sh file on Terminal.app:
$ fork sh
bash: fork: command not found
What's wrong with my command?
fork isn't a shell function.
You can run an executable script directly /path/to/script.
You can source/. a script to run it in the current shell . path/to/script.
You can also run the shell directly on the script bash /path/to/script.
To run a command in the background, you can put an ampersand (&) on the end.
So for example, if your command is /path/to/some/program some args here, you could run it in the background (and continue entering commands in your foreground shell) using:
/path/to/some/program some args here &
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I'm trying to run a script in my Terminal on OSX. I run it like this:
$ script.sh input.txt output.txt
-bash: Script.bash: command not found
This script has worked before (with no changes to it) and it appears in the working directory when using the ls command. I don't know if this means anything but previously my script files had a .s logo on their filetype picture and now it is blank, like a .txt file (in Finder). Any help would be much appreciated! I tried using script.bash and the same thing happens. Thanks!
try "./COMMAND HERE"
or ". COMMAND HERE"
you need to have an explicit path if the script isn't in your $PATH
./script.sh input.txt output.txt
also you will want to make sure that the script is set as being executable
like:
chmod 777 script.sh
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Reading the make's manual page:
`shar'
Create a shell archive (shar file) of the source files.
What is a shar?
It's a shell archive, a self extracting executable shell script which is meant to be a convenient way to ship archives of files and have them appear simply by running the script.
An example is shown in the transcript below which gives only one file from the archive, output.txt:
pax> cat shar.bash
#!/bin/bash
tr '[A-Za-z]' '[N-ZA-Mn-za-m]' >output.txt <<EOF
Uryyb sebz Cnk.
EOF
pax> ./shar.bash
pax> cat output.txt
Hello from Pax.
That's a fairly simplistic one since it only delivers one file, and it doesn't compress it at all, but it should give you the general idea.
A real one would probably give you something like a set of files combined with tar, gzip and uuencode, which would then be passed through uudecode, gunzip and tar to deliver the original content.
A self-extracting archive: a shell script that extracts some data contained in it.
Wikipedia has more: http://en.wikipedia.org/wiki/Shar
It's a kind of self-extracting archive.
It's a bit dangerous (like a self-extracting .exe on Windows), because it runs itself to extract itself, so it could potentially do all kinds of other things that you did not expect.
I think this is what Oracle uses to distribute the JVM on Linux (to make you click through a license agreement first).
Normally, people would just use tar archives (which cannot execute arbitrary code, but also not show any dialogs).
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
the name.sh already save in C:\Documents and Settings\user, i type sh name.sh
sh: testing.sh: No such file or directory
any help will be appreciated!
You can just type ./name.sh and your script should run.
If your current directory is not in your $PATH, adding the ./ tells the shell to look there.
The other possibility is that you're not currently in the right directory. If the result of pwd shows you are not in C:\Documents and Settings\user, then you will need to cd to that directory, or move the script to whatever directory you are in.
Add ./ in front of the name. ./name.sh