Dos prompt on linux

Is there a Linux command or a script that I could write and run on linux to call a Windows DOS command prompt? If so, how?

I would like to automate an existing process that involves executing programs on a Linux server which would then send output file(s) to be edited by excel. The resulting .csv files must be run on a Windows DOS command prompt. If I would like to automate this process, one of the things that I would like to know is if it’s possible for me to write and run a script on a Linux server to call a Windows DOS command prompt. Any suggestions?

2 Answers 2

If you install Cygwin (https://www.cygwin.com/), it provides an SSH server for Windows. Once installed and configured, you can access it like any other SSH server. In the Cygwin SSH server, you can execute both Cygwin compiled programs and Windows native programs (Windows native programs will show the GUI on the users desktop, even though you have forwarded the X). To execute a DOS command prompt, just type «cmd.exe». If you want the DOS command prompt to execute a bat file and exit, you can do it like this:

cmd.exe /C ‘»C:\Path\to\file 1.bat»‘ (The single quotes are due to as the name has spaces, the cmd parameters needs the double quotes, and to avoid Bash to take them out, we have to put them between single quotes).

Note: If you want a quick Cygwin installation, you can try this package: «http://www.gage.es/glab-download». This installation is from an open source program (gLAB), which already has an automatic Cygwin installation embedded. Just erase the gLAB later, and you will have a Cygwin with everything you need.

It is a gaping security hole since it allows password-less connection to your Windows box from anywhere, but if you are only doing this at home inside a private network, it may be ok.

Basically, you would install the tiny program called netcat (also known as nc ) on your Windows box. It is already installed on most Linux boxes.

Then on your Windows box, in a Command Prompt you tell netcat to listen on port 10000 (or any other one you choose) and run cmd.exe to process whatever it receives on that port:

On your Linux box, you connect to port 10000 of your Windows box and then the commands you type in your Linux box are processed by cmd.exe on your Windows box. So, assuming your Windows box has the IP address 192.168.0.10:

nc 192.168.0.10 10000 process file.xls 

Of course, installing an ssh server is more secure, but this approach has the advantage that it requires very little setup at all.

Читайте также:  What is linux tutorial

Another option might be to share a directory between the Linux and Windows machine and have the Windows machine regularly (every 10 seconds maybe) check the directory for new files and if it sees any process them and then move them to a different directory called, say Processed so that they don’t get processed again on the next iteration. So there would be a BATCH script running on Windows that just did a loop:

@echo off :top echo Checking for files. FOR /F ["options"] %%parameter IN (*.CSV) DO ( process file move file to processed subdirectory ) sleep 3 goto top 

See ss64 website for syntax of FOR loop.

Источник

Запуск DOS-приложения в Linux

Необходимость запуска DOS-приложений под Linux возникает нечасто, но случается. Вот как-то и со мной случилось, решил поделиться опытом, может, кому пригодится.

А нужно было запустить кем-то, когда-то написанное приложение для поликлиники, работающее на Foxpro под DOSом, в Linux, т.к. денег на покупку Windows лицензий не нашлось.

Исходные данные:
Suse Linux Enterprise Desktop 10.3 — рабочие станции.
Suse Linux Enterprise Server 10.3, на нем шара на Samba (я же до этого и расшаривал для работы с Windows рабочих станций, т.к. на лицензию для Win-сервака тоже денег не было), имя шары, как ни странно, — SHARE.
Происходило всё 2-3 года назад, поэтому версии SLED и SLES на момент установки были не такие уж и древние.

Т.к. сервер уже настроен, то все нижеописанные манипуляции производим на десктопе.
Ставим из репозитория, или отдельно скачиваем dosemu-xxx.rpm.

Ещё нам понадобятся кириллические шрифты (далее по тексту папка XFonts), не помню уже где я их взял, приложу в архиве к статье.

Создаём папку, куда смонтируем шару, прописываем монтирование в fstab и монтируем:

su mkdir /mnt/dos chmod 777 /mnt/dos echo "//192.168.0.130/SHARE /mnt/dos cifs iocharset=utf8,codepage=cp866,noperm,forcemand,direct,nounix,nolock,username=user,password=userpassword,rw 0 0" >> /etc/fstab mount /mnt/dos

небольшое пояснение: 192.168.0.130 — IP сервера, user и userpassword берём из пользователей на сервере, которым разрешён доступ к Samba-шаре.

cp -rf XFonts /usr/X11R6/lib/X11/fonts/

прописываем папку подобно остальным шрифтам в файле /etc/X11/xorg.conf, и добавляем их в систему командой:

В /etc/dosemu.conf добавляем или изменяем в соответствующих разделах следующие опции (у меня в итоге только эти опции и остались):

## Terminal related settings # Character set used externally to dosemu $_external_char_set = "utf8" #кодировка в Linux # Character set used by dos programs $_internal_char_set = "cp866" #кодировка в DOS ## Keyboard related settings $_layout = "ru" #задаём раскладку ## Printer and parallel port settings $_lpt1 = "lp -o media=a4 -o cpi=11" #подключаем принтер, в моём случае матричник на LPT порту #или #$_lpt1 = "iconv -f cp866 -t utf8 | lp -o media=a4 -o cpi=11 -d printername" ## Setting specific to the X Window System (xdosemu, dosemu -X) $_X_font = "vgacyr" #подключаем кириллические шрифты

В файл autoexec.bat, находящийся в папке /usr/share/dosemu/drive_z пишем следующее (. при копировании # и пояснения убрать. ):

@echo off rem autoexec.bat for DOSEMU + FreeDOS path z:\bin;z:\gnu;z:\dosemu;p:\ovl1;p:\ovl;p:\prv # ovl1;p:\ovl;p:\prv - папки запуска программы в DOS; set HELPPATH=z:\help set TEMP=c:\tmp blaster prompt $P$G unix -s DOSDRIVE_D if "%DOSDRIVE_D%" == "" goto nodrived lredir d: linux\fs%DOSDRIVE_D%:nodrived lredir p: linux\fs/mnt/dos # назначение соответствия папки Linux диску DOS unix -s DOSEMU_VERSION echo "Welcome to dosemu %DOSEMU_VERSION%!" unix -e xmode -fullscreen on # запуск Dosemu в полноэкранном режиме lin.bat # батник запуска программы в DOS

Для полной ясности вот содержание lin.bat (. при копировании # и пояснения убрать. ):

@ echo off p: # переходим на диск p: cd ovl1 # далее в рабочую папку p:\ovl1\reg01.fxp # запускаем программу (расширение .fxp у меня, у Вас скорее всего будет .exe, если не Foxpro) xmode -fullscreen off # после окончания работы программы выходим из полноэкранного режима exitemu # выходим из досэмулятора

Делаем первый запуск, командем:

Читайте также:  Netbackup client for linux

получим фигвам, потому что нет файла lin.bat, исправляем созданием в домашней директории, в папке .dosemu/drive_c (папка создаётся при первом запуске эмулятора) этого файла с вышеприведённым содержанием.

Ещё раз запускаем dosemu и вуаля, наша досовская прога работает, показывает текст на русском языке и даже распечатывает под Linux.

Мои изыски относились к определённой программе, но, думаю, таким способом, с заменой путей и имён файлов, запустятся если не все, то многие приложения работающие под DOS.

P.S.
Если при запуске dosemu ловим:

>LOWRAM mmap: Недопустимый аргумент

То дописываем в /etc/sysctl.conf

Источник

How to get to an MS-DOS prompt or Windows command line

Windows command line (DOS)

Computer Hope

Below are steps on getting to an MS-DOS prompt or Windows command line in all versions of Microsoft operating systems.

Get to Command Prompt in Windows 10

For some commands and options to work in the Windows 10 command line, you must run the command line with administrative privileges. To do this, right-click the cmd icon and select Run as administrator.

Get to Command Prompt in Windows 8

  1. Move the mouse pointer to the very bottom-left corner of the screen and right-click, or press Windows key + X .
  2. In the power user task menu, select either Command Prompt or Command Prompt (Admin).

Get to Command Prompt in Windows Vista and 7

For some commands and options to work in the Windows Vista and 7 command line, you must run the command line as administrator. To do this, right-click the cmd icon and select Run as administrator.

If you’re attempting to get into an MS-DOS prompt to troubleshoot the computer, boot the computer into Safe Mode.

Get to Command Prompt in Windows NT, 2000, and XP

If you are attempting to get into an MS-DOS prompt to troubleshoot the computer, boot the computer into Safe Mode.

Windows 2000 and XP users who cannot boot the computer into Normal Windows mode or Safe Mode can also enter and use the Recovery Console to manage their computer from a prompt. See: How to use the Windows Recovery Console.

Finally, if you are experiencing issues getting into Windows NT, 2000, or XP, it may be necessary to run troubleshooting steps from an MS-DOS prompt. We recommend the Network Administrator gain access either using a standard MS-DOS boot diskette or the ERD diskettes created after the installation of Windows NT. Also, they may access MS-DOS by booting from a Windows XP CD.

Get to Command Prompt in Windows 95, 98, and ME

If you can get into Windows 95, 98 or ME, you can get to an MS-DOS prompt by following the steps below.

Following the steps above opens an MS-DOS shell. However, if you are attempting to troubleshoot an issue with the computer and are using Microsoft Windows 95 or Windows 98, we suggest you restart the computer into MS-DOS. To do this, follow the steps below.

Читайте также:  Linux криптопро скопировать контейнер

How to restart the computer into an MS-DOS prompt

  1. Click Start.
  2. Click Shutdown.
  3. Choose the option to restart the computer to an MS-DOS prompt.

If you cannot get into Windows 95 or Windows 98 to get to an MS-DOS prompt, follow the instructions below (Windows ME does not have this option).

  1. Reboot the computer
  2. As the computer is booting, press the F8 key when you hear a beep or when you see «Starting Windows 95» or «Starting Windows 98.» Windows 98 users sometimes may find it easier to press and hold the left Ctrl key as the computer is booting.
  3. If done properly, the user should get to a screen similar to the below screen.
Microsoft Windows 95 Startup Menu ============================= 1. Normal 2. Logged (\BOOTLOG.TXT) 3. Safe Mode 4. Step-by-step confirmation 5. Command prompt only 6. Safe mode command prompt only Enter a choice: 1 F5=Safe Mode Shift+F5=Command prompt Shift+F8= Step-by-step confirmation [N]

Getting to MS-DOS

If you are running MS-DOS with no other operating systems, the computer should be booting into an MS-DOS prompt automatically, unless you have a shell or other program loading automatically.

If the computer cannot load MS-DOS, reboot the computer and as the computer is booting, press the F5 key when you see the message «Starting MS-DOS» or the MS-DOS version. Pressing this key should load the default settings for MS-DOS.

If this opens an MS-DOS prompt and you want to prevent further occurrences, edit the autoexec.bat or the config.sys files and remark any bad lines.

Get to MS-DOS in Windows 3.x

If you are running Windows 3.x, it is likely that the computer is booting into Windows automatically and bypassing the MS-DOS prompt. If the computer loads successfully into Windows, to exit to an MS-DOS prompt, from the Program Manager, click the file menu and select Exit.

If the computer cannot load MS-DOS, reboot the computer and as the computer is booting, press the F5 key when you see the message «Starting MS-DOS» or the MS-DOS version. Pressing this key should load the default settings for MS-DOS.

If you do not want Windows 3.x to load automatically into Windows 3.x, edit the autoexec.bat file and remove the «win» line.

Other operating system

If you want a command line, you more than likely want to access the Shell or Terminal for your operating system, not MS-DOS.

If you are using another operating system (e.g., OS/2 or Linux variant) and you need to get to an MS-DOS prompt, use an MS-DOS boot diskette, unless you are dual booting the computer. Keep in mind that booting from an MS-DOS diskette won’t allow you to access the files used with other operating systems. However, if you’re erasing everything and starting over, this would allow you to delete all pre-existing information and start over.

  • How to create or delete an Instagram account.
  • See our Windows command line definition for further information and related links.
  • See our MS-DOS and Windows command line page for a list of all command line commands.
  • MS-DOS and Windows command line help and support.

Источник

Оцените статью
Adblock
detector