shell script for tcpdump

Dear friends,

       I had a one problem 

"
#!/bin/bash
com=/usr/sbin/tcpdump

da=/bin/date

DATECODE=$da +%d-%m-%y

     pa=/root/Desktop/backup-$DATECODE

if ! -f $da ];
then
$com > /root/Desktop/backup-$DATECODE
else
$com > /root/Desktop/folder-$DATECODE/backup-$DATECODE
fi "

  this is my shell script its working when i run in mysystem  but only thing if file is already there i need to creat new folder in that i need  to put tcpdump backup file 

if run this first thing is working second one is not working tcpdump can`t creat the folder. before i did now i lost my all scripts

Surely you meant to test the existence of $pa, not $da? :wink:

Dear ken_yap,
what u mean i don`t what u r saying man

When do you create the folder-$DATECODE ?
I don’t see the command in your script.

if ! -d $pa ]; then
mkdir --mode=0700 $pa
else
$com > $pa/backup-$DATECODE
fi

By the way, it is what ken_yap asked you.
If you wanted to test if the folder was existing or really test the date…

hum, I made this with:

pa="/root/Desktop/folder-$DATECODE"

You should be able to adapt it with the test in your code to see if the file is on the Desktop.

(I don’t understand why you add the $DATECODE on both the folder and the file)

he`z´ got’’ it aight use it just wutfbbqlollanguage.