LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-09-2005, 11:58 AM   #1
trajjm
LQ Newbie
 
Registered: Oct 2005
Posts: 3

Rep: Reputation: 0
shell script with "netcat > file" at boottime


Hi Folks,

i try to start this script at boottime:

Code:
nohup nice netcat 192.168.1.100 2000 > cardreaderfile &
to dump the traffic from a rfid-reader in a file.
When i execute this script by hand in a terminal, it works perfect and runs i the background!
but inserting the script in a initfile it does not start.

In an different project i was using a pipe after netcat :
Code:
nohup nice netcat 192.168.1.100 2000 | somescript &
and it works also at boottime!!

So i thing the probleme is somewhere with the fileoperator ">"

Has someone an idea how to get this working?
many thanks
joerg
 
Old 10-10-2005, 05:52 AM   #2
cardy
Member
 
Registered: Jan 2005
Location: Shropshire, England, UK
Distribution: RedHat, Fedora, CentOS..........
Posts: 121

Rep: Reputation: 19
Which file are you using to start this script ? Obviously you will need to ensure it is run after the network interfaces have been started.

Also have you checked the file nohup.out (which is created by the nohup command) to see what output was created (if any).

Last edited by cardy; 10-10-2005 at 05:58 AM.
 
Old 10-10-2005, 06:42 AM   #3
trajjm
LQ Newbie
 
Registered: Oct 2005
Posts: 3

Original Poster
Rep: Reputation: 0
i have created a startscript in the init.d directory (from the suse-skeleton).
this startscript runs only in init level 3 after the network is up and calls the following script:

Code:
#! /bin/bash
nohup nice netcat 10.40.123.1 2000 | /keycard/key01 &
nohup nice netcat 10.40.123.2 2000 | /keycard/key02 &
nohup nice netcat 10.40.123.3 2000 | /keycard/key03 &
nohup nice netcat 10.40.123.4 2000 | /keycard/key04 &

nohup nice netcat 10.40.123.5 2000 > key05.txt &
all the netcat commands which pipes ther output to another script , are running fine in the background..
the netcat command which should redirect his output in the file > key05.txt is not starting :-( (there is also no nohup.out file generated)
if i start this script in a terminal, everything is working fine !
hmm?
 
Old 10-10-2005, 06:54 AM   #4
cardy
Member
 
Registered: Jan 2005
Location: Shropshire, England, UK
Distribution: RedHat, Fedora, CentOS..........
Posts: 121

Rep: Reputation: 19
Sorry I should have noticed earlier.

Try taking off the nohup on the command which is using the redirect (>). The reason for this is that nohup redirects all output to the file nohup.out thus your trying to redirect output which has already been redirected.
 
  


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
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 07:42 AM
How to write a bash script to replace all "KH" to "K" in file ABC??? cqmyg5 Slackware 4 07-24-2007 09:00 AM
Starting Java from shell script (Exception in thread "main") rolf_mueller Linux - Software 5 10-30-2004 02:11 AM
1. shell script "find and replace" on text 2. java GUI application randomx Programming 4 03-05-2004 01:01 PM

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

All times are GMT -5. The time now is 12:15 AM.

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