UNIX батник

GAD_FATAL

надо батник в юниксе замутить. как?

disna

текстовым редактором

GAD_FATAL

отлично, а какое требование к имени файла?
в досе помнится шаблон *.bat

july

Никакого. Есть требование на права (файл должен быть исполняемым).
пример файл hello.111:

#!/bin/bash
echo "Hello, this is a batch :)"

Права:

chmod u+x hello.111

Первая строка в файле указывает, какой интерпретатор читает и выполняет твои команды. В данном случае, это bash, находящийся в каталоге /usr/bin

disna

никакого
он даже может не быть исполняемым, если запускать так:
sh filename

uncle17

зачем тебе юникс?

Elina74

предварительно выставить атрибут +x
./file.sh

disna

заметь, он не спросил, какой линукс ставить

uncle17

я тоже уже два года не спрашиваю:)

GAD_FATAL

не песдеть! UNIX офигенная система для ПК.
а за советы спасибо.

Andbar

не песдеть! UNIX офигенная система для ПК.
а за советы спасибо.
да правильно, настоящие не_ламаки сидят на ней.

Ivan8209

man 2 execve
---
"Аллах не ведёт людей неверных."

sergey_m

> я тоже уже два года не спрашиваю:)
Но всё время жалуешься, что не можешь выбрать.

Olenenok

и причём здесь execve (const char *filename, char *const argv[], char *const envp[]); ?

Ivan8209

Читать надо дальше SYNPOSIS

EXECVE(2) NetBSD System Calls Manual EXECVE(2)

NAME
execve -- execute a file

LIBRARY
Standard C Library (libc, -lc)

SYNOPSIS
#include <unistd.h>

int
execve(const char *path, char *const argv[], char *const envp[]);

DESCRIPTION
execve transforms the calling process into a new process. The new
process is constructed from an ordinary file, whose name is pointed to by
path, called the new process file. This file is either an executable
object file, or a file of data for an interpreter. An executable object
file consists of an identifying header, followed by pages of data repre-
senting the initial program (text) and initialized data pages. Addi-
tional pages may be specified by the header to be initialized with zero
data; see a.out(5).

An interpreter file begins with a line of the form:

#! interpreter [arg]

When an interpreter file is execved the system runs the specified
interpreter. If the optional arg is specified, it becomes the first
argument to the interpreter, and the name of the originally execved
file becomes the second argument; otherwise, the name of the originally
execved file becomes the first argument. The original arguments are
shifted over to become the subsequent arguments. The zeroth argument,
normally the name of the execved file, is left unchanged. The inter-
preter named by interpreter must not itself be an interpreter file.

---
"Аллах не ведёт людей неверных."

Nailgenuine

надо бантик в юниксе замутить. как?

disna

и кучка

Olenenok

я знаю, что делает эта функция. только мне кажется, что здесь разговор не про запуск скрипта из программы на С

Ivan8209

Ты так и не прочитал man, там всё сказано яснее некуда:

An interpreter file begins with a line of the form:

#! interpreter [arg]

When an interpreter file is execved the system runs the specified
interpreter. If the optional arg is specified, it becomes the first
argument to the interpreter, and the name of the originally execved
file becomes the second argument; otherwise, the name of the originally
execved file becomes the first argument.

Тебе по буквам повторить?
---
"Аллах не ведёт людей неверных."

Olenenok

а, ты про #!
ну дык я уже и забыл, как про это можно не знать

Viktory-s

ну дык я уже и забыл, как про это можно не знать
Так это с первого поста было ясно. Тут задача была проще.
Оставить комментарий
Имя или ник:
Комментарий: