Когда я вызываю telnet для подключения к дневному серверу из интерактивной оболочки, он работает нормально. Однако, когда тот же вызов telnet выполняется из сценария оболочки, запущенного cron или каким-либо процессом демона bash, он не дает никакого результата. Я связал оба звонка, и вот они:
Успешный:
execve("/usr/bin/telnet", ["telnet", "192.168.0.11", "13"], [/* 24 vars */]) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|0x4000000, -1, 0) = 0x40005000
stat("/etc/ld.so.cache", {st_mode=S_IFREG|0644, st_size=3128, ...}) = 0
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
mmap2(NULL, 3128, PROT_READ, MAP_SHARED, 3, 0) = 0x40006000
close(3) = 0
stat("/etc/ld.so.preload", 0xbea5d8d4) = -1 ENOENT (No such file or directory)
open("/lib/libc.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=324423, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|0x4000000, -1, 0) = 0x40007000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\320\253\0\0004\0\0\0\0"..., 4096) = 4096
mmap2(NULL, 376832, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4000e000
mmap2(0x4000e000, 319264, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x4000e000
mmap2(0x40064000, 4935, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x4e) = 0x40064000
mmap2(0x40066000, 14712, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40066000
close(3) = 0
munmap(0x40007000, 4096) = 0
munmap(0x40006000, 3128) = 0
stat("/lib/ld-uClibc.so.0", {st_mode=S_IFREG|0755, st_size=20486, ...}) = 0
mprotect(0x40064000, 4096, PROT_READ) = 0
mprotect(0x4000c000, 4096, PROT_READ) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
getuid32() = 0
ioctl(0, TIOCGWINSZ, {ws_row=55, ws_col=203, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
brk(0) = 0x91000
brk(0x92000) = 0x92000
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(13), sin_addr=inet_addr("192.168.0.11")}, 16) = 0
setsockopt(3, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
rt_sigaction(SIGINT, {0x667c0, [INT], SA_RESTART|0x4000000}, {SIG_DFL, [], 0}, 8) = 0
poll([{fd=0, events=POLLIN}, {fd=3, events=POLLIN}], 2, -1) = 1 ([{fd=3, revents=POLLIN}])
read(3, "Wed Apr 27 11:42:10 2011\r\n"..., 128) = 26
write(1, "Wed Apr 27 11:42:10 2011\r\n"..., 26) = 26
poll([{fd=0, events=POLLIN}, {fd=3, events=POLLIN}], 2, -1) = 1 ([{fd=3, revents=POLLIN}])
read(3, ""..., 128) = 0
write(1, "Connection closed by foreign host"..., 35) = 35
ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0
exit(1) = ?
Неудачный:
execve("/usr/bin/telnet", ["/usr/bin/telnet", "192.168.0.11", "13"], [/* 22 vars */]) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|0x4000000, -1, 0) = 0x40005000
stat("/etc/ld.so.cache", {st_mode=S_IFREG|0644, st_size=3128, ...}) = 0
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
mmap2(NULL, 3128, PROT_READ, MAP_SHARED, 3, 0) = 0x40006000
close(3) = 0
stat("/etc/ld.so.preload", 0xbe90a8f4) = -1 ENOENT (No such file or directory)
open("/lib/libc.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=324423, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|0x4000000, -1, 0) = 0x40007000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\320\253\0\0004\0\0\0\0"..., 4096) = 4096
mmap2(NULL, 376832, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4000e000
mmap2(0x4000e000, 319264, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x4000e000
mmap2(0x40064000, 4935, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x4e) = 0x40064000
mmap2(0x40066000, 14712, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40066000
close(3) = 0
munmap(0x40007000, 4096) = 0
munmap(0x40006000, 3128) = 0
stat("/lib/ld-uClibc.so.0", {st_mode=S_IFREG|0755, st_size=20486, ...}) = 0
mprotect(0x40064000, 4096, PROT_READ) = 0
mprotect(0x4000c000, 4096, PROT_READ) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbe90a714) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbe90a714) = -1 ENOTTY (Inappropriate ioctl for device)
getuid32() = 0
ioctl(0, TIOCGWINSZ, 0xbe90a9cc) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbe90a9b4) = -1 ENOTTY (Inappropriate ioctl for device)
brk(0) = 0x91000
brk(0x92000) = 0x92000
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(13), sin_addr=inet_addr("192.168.0.11")}, 16) = 0
setsockopt(3, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
rt_sigaction(SIGINT, {0x667c0, [INT], SA_RESTART|0x4000000}, {SIG_DFL, [], 0}, 8) = 0
poll([{fd=0, events=POLLIN}, {fd=3, events=POLLIN}], 2, -1) = 2 ([{fd=0, revents=POLLIN}, {fd=3, revents=POLLIN}])
read(0, ""..., 128) = 0
exit(0) = ?
Любая помощь приветствуется.