aideb
asked on
Run DOS2UNIX and then execute the command
Hi,
I have a command line that I need to reorganise
wget -O - http://kalideploy.azurewebsites.net/test.sh | dos2unix | sudo bash -x
I'm using the Linux custom script deployment and it will fetch the file for me - so I don't need wget
The script needs converted using the dos2unix before execution
I've tried a variety of different command lines but cannot work out where its going wrong
Can anyone help?
I have a command line that I need to reorganise
wget -O - http://kalideploy.azurewebsites.net/test.sh | dos2unix | sudo bash -x
I'm using the Linux custom script deployment and it will fetch the file for me - so I don't need wget
The script needs converted using the dos2unix before execution
I've tried a variety of different command lines but cannot work out where its going wrong
Can anyone help?
Your example looks like you are piping one command to the other, which is fine, but the dos2unix portion of the command is missing parameters. Here is the manual: http://waterlan.home.xs4al l.nl/dos2u nix/dos2un ix.htm
Can you try:
echo $(wget -O - http://kalideploy.azurewebsites.net/test.sh) | dos2unix | sudo bash -x
What is the output of the wget command?
echo $(wget -O - http://kalideploy.azurewebsites.net/test.sh) | dos2unix | sudo bash -x
What is the output of the wget command?
ASKER
@Frank
What parameter do you think is missing?
For clarity, the command above runs when executed normally
When running via Azure, I would usually run
sh script.sh
however I need to run it through the dos2unix converter
What parameter do you think is missing?
For clarity, the command above runs when executed normally
When running via Azure, I would usually run
sh script.sh
however I need to run it through the dos2unix converter
ASKER
@Gerwin
Sorry, that just hangs
oot@KaliB005:/home/labuser # echo $(wget -O - http://kalideploy.azurewebsites.net/test.sh) | dos2unix | sudo bash -x
--2017-01-16 13:29:51-- http://kalideploy.azurewebsites.net/test.sh
Resolving kalideploy.azurewebsites.n et (kalideploy.azurewebsites. net)... sudo: unable to resolve host KaliB005
13.95.238.192
Connecting to kalideploy.azurewebsites.n et (kalideploy.azurewebsites. net)|13.95 .238.192|: 80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2511 (2.5K) [application/x-sh]
Saving to: ‘STDOUT’
- 100%[===================== ========== ========== ========== ========== >] 2.45K --.-KB/s in 0s
2017-01-16 13:29:54 (544 MB/s) - written to stdout [2511/2511]
Sorry, that just hangs
oot@KaliB005:/home/labuser
--2017-01-16 13:29:51-- http://kalideploy.azurewebsites.net/test.sh
Resolving kalideploy.azurewebsites.n
13.95.238.192
Connecting to kalideploy.azurewebsites.n
HTTP request sent, awaiting response... 200 OK
Length: 2511 (2.5K) [application/x-sh]
Saving to: ‘STDOUT’
- 100%[=====================
2017-01-16 13:29:54 (544 MB/s) - written to stdout [2511/2511]
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@omarfarid
I get the following error
No such file or directory
I get the following error
No such file or directory
ASKER
@omarfarid
It outputs the contents of the script
Thanks
It outputs the contents of the script
Thanks
if the script is multiple lines then you may need to store in file then execute that file. It may also be that the script has folders of files names that it can't find
>> I would usually run sh script.sh <<
I understand that there is a script "script.sh" in DOS format which you want to run, converting it to Unix format "on the fly", leaving the original "script.sh" as is. If I'm right, try:
dos2unix < script.sh | sh
The above will not work if the script itself needs to read from stdin or if the script expects command line arguments!
I understand that there is a script "script.sh" in DOS format which you want to run, converting it to Unix format "on the fly", leaving the original "script.sh" as is. If I'm right, try:
dos2unix < script.sh | sh
The above will not work if the script itself needs to read from stdin or if the script expects command line arguments!
What is your goal with that test script you are downloading?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The issue is that I need an easy way in which to edit the script - and I'm editing on a Windows based PC. Each time I save the file on Windows, I need to run it through Dos2Unix else it fails
Perhaps I'm going to have to do all the edits on the remote Linux box and then upload from there...
Does anyone have a better solution?
Perhaps I'm going to have to do all the edits on the remote Linux box and then upload from there...
Does anyone have a better solution?
ASKER
I'm trying to build multiple VM's using the Linux custom script extension on Azure
https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-linux-extensions-customscript
https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-linux-extensions-customscript
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I really wanted to be able to continue to use the web based App Service editor on Azure to edit - hence the use of Dos2Unix
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is http is the only way to access the file and download the script file? If you have ftp access then using ftp you can download file as text which will convert the control M
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi woolmilkporc
Yes, I tried your suggestion - Thanks
It works fine from a terminal session but not from the Azure template
Yes, I tried your suggestion - Thanks
It works fine from a terminal session but not from the Azure template
ASKER
Thanks everyone for all your input.
I've revised my approach as suggested and I'm now editing the file on Windows using Notepad++ preserving the file encoding thus avoiding having to fix it when it arrives on the Linux machine. Its not quite how I wanted to do it, however it is working!
Thanks
I've revised my approach as suggested and I'm now editing the file on Windows using Notepad++ preserving the file encoding thus avoiding having to fix it when it arrives on the Linux machine. Its not quite how I wanted to do it, however it is working!
Thanks