PuTTY run sh can't install fileinfo extension - shell

I have a DreamHost server, and I would like to install the fileinfo extension.
I managed to create a custom php.ini file that's cool, but I'm totally stuck at this part in their documentation:
Please make sure to run 'dos2unix fileinfo_ext.sh' from the shell if you use a Windows-based editor to create this file.
So I am on Windows and running PuTTY and I have no clue about this part.
I copied fileinfo_ext.sh to my cgi-bin directory where my custom php.ini file is, but how do I go further? I'm totally lost how to run this command.
How can I do it?

"dos2unix" is a utility used to convert file from Windows line endings (CR+LF) to Unix line endings (LF).
So if you use Notepad to edit the file it will have Windows line endings. So dos2unix should be used on your computer (for that file) before sending it by FTP (or executing it on the host if you have ssh access and they have dos2unix).
But if you already use an editor which supports converting to Unix line endings, like UltraEdit or Notepad++ then all you need is to do a "convert to Unix" before saving the file.

You run the command as explained in the message. SSH to the server and login. Then cd to the location of the file, something like cd /path/to/your/site/cgi-bin and then run dos2unix fileinfo_ext.sh.
I hope this helps.

Related

Ftp Windows Command Line Command Not Working

I'm using Windows command line for getting some files from a ftp server.
I need to change the local directory during the session.
I tried using 'lcd' command but it's not working. I displayed that the command is executed correctly but when i download the files they are downloaded on another directory (default?).
Retyping 'lcd' to show the actual local directory i can see it does not change.
The code i used is written below
lcd C:\Myfolder\MySubFolder
I tryed also the cmd with administrative priviledges, but it is the same.
Thank You.

How to run zookeeper.sh file in windows

I am following this tutorial where i have to run this command in order to start the zookeeper server.
./bin/zookeeper-server-start.sh config/zookeeper.properties
But the problem is this command is not working properly. I found that .sh file is bash file that required cygwin. I have installed it and then run command like this
C:\cygwin64\bin\bash.exe ./bin/zookeeper-server-start.sh config/zookeeper.properties
But it is showing:
I can confirm that in bin directory the file is exsits. what i am doing wrong?
Here is my directory snapshot from where i running the command:
Note: I have successfully tested bin/windows zookeeper bat file but i want to run it through .sh file as the kafka security tutorial which i am following using this.
From your screenshot, I conclude that you are using Cygwin. So, please add the cygwin tag to your question.
As you can see from the error message, the command dirname is not found by bash, so assuming that your Cygwin installation is not broken, I assume that the PATH is not set correctly; in your setup, dirname.exe should be in C:/cygwin64/bin (please verify this).
Your usage of bash.exe is a bit unusual in that you run it directly from a Windows cmd prompt. The more common way would be to use it from the 'Cygwin Terminal', which you get created a Windows-link to, when installing Cygwin, or to use another suitable Terminal program; I'm using for instance mintty for this task (also available via the Cygwin installer).
Having said this, it is possible to run bash.exe in the way you are doing it, but you then have to ensure, that at least the PATH is set up correctly. One possibility to do this, is to add C:\cygwin64\bin to your Windows PATH, but this has the drawback, that some commands have the same name in the Windows world and in Cygwin, though they serve a completely different purpose, and this will bite you sooner or later. Another problem is that at some point, you will rely on other bash specific setups besides the PATH.
A better way to accomplish your goal is IMO to ensure, that the system wide bash-initialization files are sourced by bash. If I have to run the script from a Windows cmd prompt, I would run it by
C:\cygwin64\bin\bash.exe --login YOURSCRIPT
This will read the file (in your setup) C:\cygwin64\etc\profile before running YOURSCRIPT, so you can check, that the PATH is correctly set there, by looking at this file. In a default installation, this should be the case.
After having read this file, it will try to read the file .bash_profile in your Cygwin HOME directory, so if you need additional settings for your (non-interactive) bash-scripts, create this file and put your settings there.

use Ubuntu at virtual box based on windows 7 cannot edit text

I have a problem that
1. my laptop is X86 win7 & install a virtual box.
2. Based on virtual box, I installed a Ubuntu.
Now I share a folder between win7 & Ubuntu.
And edit a bash file on windows by, ex UltraEdit.
After then, when I run the bash on Ubuntu.
It said:
mkdir: cannot create directory ‘dvbpsi\r’: Protocol error
cp: cannot stat 'src/table/.h': No such file or directory*
It seems that \r is wrong.
Instead, if I tried to store in virtual box, it shows the wrong msg below:
It seems that I CANNOT store anything from virtual OS to a shared folder.
Is there a smart way to resolve it?
Thanks in advance!!
UltraEdit can create, edit and save text files with DOS (\r\n) or UNIX (just \n) or MAC (just \r) line terminators.
The line terminator type is indicated for active file in status bar at bottom of UltraEdit main window.
The conversion between the various line terminator types can be done at any time in UltraEdit using for example the DOS to UNIX conversion command or on using Line terminator option in Save As dialog.
The default line ending type for new files can be also configured in configuration at
Advanced - Settings/Configuration - File Handling - DOS/Unix/Mac Handling.
I suggest following configuration settings for using UltraEdit mainly for editing Windows text files and only sometimes for Unix shell scripts:
Default file type for new files ... DOS
Unix/Mac file detection/conversion ... Automatically convert to DOS format
Only recognize DOS terminated lines (CR/LF) as new lines for editing ... not checked
Save file as input format (Unix/Mac/DOS) ... checked
Status bar shows original line terminator format (on disk) ... checked
So creating/editing shell scripts on Windows with UNIX type of line termination is easy using UltraEdit on Windows being also available for Linux and Mac.

Converting a Windows .cpp file for Unix system?

I have a .cpp file that I wrote on my Windows 8 computer and I am trying to paste its code into my schools Unix based system via Putty SSH client. The editor that is used on the Unix machines is the Vi editor. When I copy all the code from my .cpp file in my Windows computer and right click on the Vi editor and paste, the code shows up but its all over place and I can't even read it(I am pretty sure it wouldn't compile either). Is there a way to fix it so the code maintains its formatting in the Vi editor ? Thanks for any help !
There is usually a unix utility called dos2unix and one called unix2dos which will convert your file to dos or unix format.
If you have those it should just be a matter of:
dos2unix myfile.cpp myfile.cpp
Also, instead of pasting it into your editor try using pscp to copy the file to your target machine.
pscp myfile myname#hostname:/mydirectory/myfile
I think you must be getting beaten by the difference in the line endings of windows and unix.
You can try using editor like Notepad++ and save the file on windows.
Open the file in Noteapd++ and Edit -> EOL Conversion -> UNIX Format and save

using google-apps-script to try to create a bash shell script from spreadsheet

We are trying to generate a bash shell script for use on a Linux system from values stored in a Google spreadsheet and we are having difficulties.
I can create the script contents fine and save the resultant file to Google drive but the problems come about when I try to use the file on a Linux box. When the file is downloaded as plain text the encoding is set to UTF-8 which Linux thinks is a binary file when I try to execute it. The other problem we are having is the line endings are forcibly set to the host PC which is a windows box so I get CRLF not LF as required by the Linux machine. I was wondering if there was anyway in Google app scripting to forcibly give me ASCII encoding and UNIX line ending somehow. I'd rather not have to pipe the file contents through strings and dos2unix before being able to use it.

Resources