While using git bash terminal, I can't print a pdf file. In fact I can't print anything. I am using correct file name and I've tried typing:
lp file.pdf
but I get bash:
lp: command not found
I get same promt when trying to print anything using lp command.
How do you print from git bash terminal?
Git bash is an emulated bash. The standard programs available on most Linux distributions are not available there.
Windows programs are available. You can run them, but you'll have to make sure all the details are set up, and sometimes they don't like the environment.
For example, both notepad and wordpad (write) should be able to use the /p and/or /pt options, but you may have trouble getting it to find the file.
write tst
will open the file in wordpad, and
write /p tst
is supposed to print it, assumedly to the default printer, though my config seems admin-locked to something stupid.
Maybe that will help. Good luck.
Related
What I am trying to do is have my current ASCII ART appear on start up as well as have ls run so I can see my directories. I assume this is going to be a script that I will have to do so if anyone can point me in the right direction to get started that would be awesome. Thank you!
You'll most likely want to add whatever commands display your ASCII art and ls to the end of the ~/.bash_profile file. See here.
In other words, open the /Users/$USER/.bash_profile file in a text editor (or create it if it doesn't exist) and put ls at the end of the file on its own line.
This startup shell file is also called .profile or .bashrc on other linux/unix systems. More information on this behavior is available here. The scripting language for the file is bash.
I would like to use an existing DOS/Windows .bat script under a Cygwin bash shell. The .bat script creates a number of variables which need to exist after the .bat script ends.
This works, but the variables are not retained.
$ ./.phs_project_setup.bat .
It appears that this does not extend to sourcing a .bat script so that the variables it creates still exist in the environment.
$ . ./.phs_project_setup.bat .
-bash: #ECHO: command not found
-bash: SET: command not found
-bash: $'\r': command not found
-bash: REM: command not found
Any ideas on overcoming this obstacle?
What I have done is written the environment to a file, then iterated over the file using 'cygpath -u' on each value. Perhaps I have missed some, but it appears that cygpath will only change something that actually looks like a path. It does not change Oracle connect string for example; "user/pass#DB". I added 'export ' to the beginning of each line so that it can be sourced into a bash shell. It is not one step yet, but better.
Remember that Unix systems are generally case sensitive. cygwin's bash can run windows executables directly, but it's STILL case senstive. SET is not a valid bash command, while set is.
You can force it to source the file and try and run it, but it'll only be able to run shell built-in commands which have a 1:1 name correspondence to cmd commands. So set works, but #echo won't, because # means nothing to bash. Same goes for rem.
I would suggest trying to run the batch script using the batch interpreter (aka the COMSPEC environment variable, which is simply CMD) and then echoing out the environment it has set up as presented in this question: How I can use PowerShell with the Visual Studio Command Prompt?
You can then try and set up the environment in a similar fashion. Note that you may have a problem with the direction of slashes, drive names and other stuff like that
Sounds like you need to run the batch file and then start cygwin. If so, call the batch file from whatever file you use (cygwin.bat for example) to start cygwin. Then the variables should be available.
Alternatively, I've also moved the required bits into the proper unix configuration files to achieve the same results.
For some reason, when I try to call PDFtk from Matlab (pdftk *.pdf cat output combFile.pdf), I get a /bin/bash: pdftk: command not found error, but I can run the same command in terminal in the same directory with no problem. I have restarted my system, but that did not seem to help. I am running Mac OSX 10.9.1 and Matlab 2013b. I do not want to use the absolute path to PDFtk, because it needs to be cross-platform compatible.
EDIT: This may help. When I echo $PATH in Matlab I get /usr/bin:/bin:/usr/sbin:/sbin. When I do it in terminal, I get /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin. Then I did which pdftkand it returned /usr/local/bin/pdftk Is there anyway to add the /usr/local/bin/ path to Matlab?
I believe that the export PATH idea would probably be better for a single system (note: I have not tested it), but I needed my script to be used on several Mac and Linux machines that are out of my control. This is what I ended up using (yes, I know that this will break on Windows, but that is ok)
if(ismac)
system('/usr/local/bin/pdftk myfig[0-9][0-9].pdf cat output myfigCombined.pdf');
else
system('/usr/bin/pdftk myfig[0-9][0-9].pdf cat output myfigCombined.pdf');
end
Originally, I was using if(isunix) for the second command, but presumably because of Mac's unix architecture both commands were being executed.
EDIT: I was able to test it on Linux and it worked perfectly. I suppose this would be the syntax for Windows, but I do not have access to a Windows machine with PDFtk and Matlab installed, so no guarantees (also, I am not sure that I did the path quotation marks right...):
elseif (ispc)
system('"C:\Program Files (x86)\PDFtk Server\bin\pdftk" myfig[0-9][0-9].pdf cat output myfigCombined.pdf');
It seems that your $PATH environment variable is not exported to Matlab. Reading
http://www.mathworks.com/matlabcentral/newsreader/view_thread/255609
I'd suggest to add a
export PATH=$PATH:<Path-to-your-PDFtk-binary>
in your .bash_profile
#!/bin/sh
echo "Hello from sh"
When I run this program (hello.sh) I get a command not found error. I'm using cygwin on Windows and I looked at cy's FAQ. It said to change the permissions to 755. I already did that and still no luck. I get the same error with these other two programs.
#!/usr/bin/env python
print "Hello from python"
#!/usr/local/bin/perl
print "Hello from perl\n";
Any answers are appreciated. Thanks.
As has already been said, you need to add the Cygwin binaries to your path. To do so, right click on "My Computer", click "Properties", then "Advanced", then "Environment Variables".
Create a new environment variable with name CYGWIN_HOME and value C:\cygwin (or wherever you installed cygwin. The default location is C:\cygwin\ so this should probably work for you).
Then edit the environment variable named "PATH", and tack on the following to the end:
;%CYGWIN_HOME%\bin;%CYGWIN_HOME%\sbin;%CYGWIN_HOME%\usr\bin;%CYGWIN_HOME%\usr\sbin;%CYGWIN_HOME%\usr\local\bin;%CYGWIN_HOME%\usr\local\sbin
Close your command prompt, then reopen it. The cygwin binaries should now be available. You can double-check this by typing "which bash". It should report the location of your bash executable
I was getting the "command not found" error on a Perl script. That script has the shebang line: "#!/usr/bin/env perl" as the first line and my user is the owner who has execute permissions. I was trying to run the script using the command line "ppminstall.pl ?" (the script is set up to display documentation for using the script if passed the '?' argument). I was cd'd to the directory containing the script. The solution turned out to be to run it using "./ppminstall.pl ?", i.e. explicitly specify the current directory. I think that you might be able to add "." to the current path and get the original command line to work, but it does seem safer to me to use "./" to run it since it's pretty explicit about where the script that you want to run is located. It may be possible for someone to manipulate your Path variable and cause you to be running a version of the script that you didn't intend. The '.' and '/' characters are easy to type without taking your eyes off the screen, so it seems like a useful habit to get into. Of course, I don't know if that is your problem, but it was mine.
Maybe caused by the wrong line break?
Open this shell in Notepad++, and then check if the line break is UNIX(LF) in the lower right corner.
If not, click the text Windows (CR LF) and then click Convert to UNIX(LF).
This works for me.
Im trying to automatically run a script using Cygwin via CMD. I basically created a BAT file that goes to the directory and executes an .SH file. SH files are accosiated with Cygwin, and I tried something like "cygwin update.sh" in the command line. But all it really does is open Cygwin. I want Cygwin to automatically run the script file. Is there any easy way to do this, I've been trying to find but can't. Thank you!
You'll want to call the shell script with a particular shell, e.g. bash.
When having Cygwin open, call which bash to figure out where the binary is located. Cygwin also comes with tools that can convert paths between Cygwin and Win32 form, which is pretty helpful in cases like yours.
There is one other thing that may work, depending on your setup. There is an environment variable named PATHEXT which declares file extensions that are deemed "executable" by CMD. This can be used to your advantage, if Windows is configured so that the shell's "open" verb executes the correct shell for the file extension .sh (in your case).
Good luck.
From Cygwin Terminal, read man mintty. Try something like the following from a Windows Command Prompt:
c:\cygwin\bin\mintty --hold always --exec /cygdrive/c/path/to/bash/script.sh
I also found this!
http://rothmanshore.com/2011/01/26/kick-off-a-cygwin-script-from-a-windows-bat-file-with-a-different-working-directory/
I didn't quite understand it at first, but then it worked as I wanted it. Just if anyone knows, is there a way to make the script run without the CMD window open?? Thanks