LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   making autosricpt for logging and send them to windows using ftp (https://www.linuxquestions.org/questions/linux-server-73/making-autosricpt-for-logging-and-send-them-to-windows-using-ftp-691413/)

vodka33us 12-18-2008 02:49 AM

making autosricpt for logging and send them to windows using ftp
 
Code:

#!/bin/bash

NAME=$(hostname)

TIME=$(date +%d%m%Y%H%M)
tail -f /var/log/xferlog > ftp$NAME$TIME.txt
tail -f /var/log/httpd/acces-log > http$NAMR$TIME.txt
ifconfig >> serverinfo$NAME$TIME.txt

HOST='192.168.72.1'
USER='vodka33us'
PASS='signmein'

ftp -i -n -u $HOST << root
user ${USER} ${PASS}

binary

put ftp$NAME$TIME.txt
put http$NAME$TIME.txt
put serverinfo$NAME$TIME.txt

quit
root

rm ftp$NAME$TIME.txt
rm http$NAME$TIME.txt
rm serverinfo$NAME$TIME.txt

SCH=$(cat /root/time_sch.txt)


if [ ! -f STOPFILE ]
then
  at -f autoscript now +$SCH minutes
fi

---------------------------------------------------------------------

time_sch is 10, the file name is autoscript
i put that file in /root and then i chmod 755 autoscript

Code:

chmod 755 autoscript
./autosript

but the result is #!bin/bash there is no file
can you help me??

robertjinx 12-18-2008 02:55 AM

you might have some problem with /bin/bash or is not properly set in the script : #!/bin/bash check it.

colucix 12-18-2008 03:22 AM

Quote:

./autosript

but the result is #!bin/bash there is no file
It is not really clear what is the error. In your post you have put a wrong executable name and a wrong sha-bang in a incomplete error message. Please, can you paste and copy the exact command and the related messages from the terminal? Moreover, use code tags to embed command lines or lines of code: it will preserve spacing and indentation.

Before you ask, to put code tags you can go in advanced mode (see the button at the bottom of the "Quick Reply" box) select the text you want to embed and press the # button from there. Or put the code tags explicitly in the text as in the following example:

[CODE]$ echo Hello vodka33us\!
Hello vodka33us![/CODE]

which will result in
Code:

$ echo Hello vodka33us\!
Hello vodka33us!


p_s_shah 12-18-2008 08:02 AM

This question may sound stupid to you, but
Have you copied the contents of file from some windows based editor like wordpad to your linux box?
OR
Have you open/modified file on windows and transferred to linux using ftp ?
====
Also try running `which bash` and `whereis bash` for knowing correct path of bash.
====
There are some other things also, which i am not able to get:
Quote:

tail -f /var/log/xferlog > ftp$NAME$TIME.txt
tail -f /var/log/httpd/acces-log > http$NAMR$TIME.txt
did you try to run this command from shell and checked whether it is working or not ?
Because `tail -f ...` is used for runtime log file entries.

robertjinx 12-18-2008 08:08 AM

Try to remove the "-f" from tail and then try to run the script like this:

sh -x autoscript or sh -x ./autoscript

Good luck!


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