LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-18-2010, 12:57 PM   #1
ausrasul
LQ Newbie
 
Registered: Aug 2010
Posts: 5

Rep: Reputation: 0
Arrow How to redirect stdin for child process (Linux Shell scripting)


Hi,
I'm trying to write a shell script that do ftp and download file periodically, this script should be called by a daemon running in the background.

the shell script "script.sh" is as follows:

Code:
yafc ftp://test:test@192.168.1.225:21 < commands
and the "commands" files is

Code:
d Root/md5* /
quit
if I run script.sh it will work just fine.
But when the daemon software calls the "script.sh", the script will send ftp login request to the ftp server, but will not even answer the username or anything.

I believe it is something about child process redirection, but I don't know how to deal with it.

This problem is not only with yafc, it is the same with any ftp client or any application like telnet and so.

can you help?
Thanks !

Last edited by ausrasul; 08-19-2010 at 10:27 AM. Reason: change the title and put more description
 
Old 08-19-2010, 10:54 AM   #2
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 101Reputation: 101
This may helps you.
 
1 members found this post helpful.
Old 08-19-2010, 06:36 PM   #3
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
Do you mean putting it in the background like this:
Code:
yafc ftp://test:test@192.168.1.225:21 < commands &
 
Old 08-20-2010, 02:26 PM   #4
ausrasul
LQ Newbie
 
Registered: Aug 2010
Posts: 5

Original Poster
Rep: Reputation: 0
Exactly
However, I've rewrote the daemon program, previously the stdin stdout stderr where closed.
Now I just opened them and now it works fine, except that it outputs text that I don't want.
So I need to test how it will work when all telnet sessions disconnect.

Thank all for responses.
But let me know if I'm doing something wrong
Imo post the daemon code when I get to my pc.
 
Old 08-21-2010, 09:02 PM   #5
ausrasul
LQ Newbie
 
Registered: Aug 2010
Posts: 5

Original Poster
Rep: Reputation: 0
I've checked the daemon software, before the script call, I've closed all the std I/O.
after openning the stdin stdout stderr in the daemon, it worked fine.

Thanks for the ideas !
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gzip: stdin: invalid compressed data--format violated ftp ascii transfer sridhar_dct3 Linux - Software 10 07-28-2012 02:25 PM
Auto FTP login, without .netrc, reconnect stdin rhlee Linux - General 0 08-10-2009 07:54 AM
ftp dyndns 1and1 redirect graugeist Linux - Newbie 1 08-28-2008 03:57 PM
redirect of ftp plz bacon22 Linux - Networking 1 03-12-2004 04:17 AM
Embedded FTP deamon rajackson Linux - Software 1 08-16-2003 12:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration