- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Korn Shell Scripting
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-14-2001 06:37 PM
тАО08-14-2001 06:37 PM
Need help and suggestions from all you geniouses out there.
I am writing a tiny script to FTP some files from few directories. I have succeeded in the beginning where the scripts once run shows all files that are modified/created on the current date. I did that with the simple "ls -al|grep $dd" where I assign the $dd to be a variable where current date will be passed in.
This is my question. Once the files are displayed , how do i write the script to only FTP over only those files that are shown.
Say for example:
Once "ls -al|grep $dd" is run, i am shown three files, how do i only isolate this three files and FTP them over, the script to FTP I have completed, only the part where to chose only that particular files that I am not sure how to do.
Please help
Thanks in advance.
Joyce
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-14-2001 06:53 PM
тАО08-14-2001 06:53 PM
SolutionYou indicate that you have a script the actually does the ftp process you want. Let's assume that that script is called "myftp.sh" and that it is passed a single argument which is the name of the file to ftp. Given this, one solution to your question is this:
cd mydirectory
for F in `ls -l | grep "$dd" | awk '{print $NF}'`
do
./myftp.sh $F
done
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2001 06:30 AM
тАО08-15-2001 06:30 AM
Re: Korn Shell Scripting
You may also want to look at rdist, its pretty useful and allows what you are trying to achieve.
You can get rdist at
http://hpux.cs.utah.edu/hppd/hpux/Networking/Admin/rdist-6.1.5
But if that is a overkill, you can write a script.
-Regards
I am RU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2001 01:19 PM
тАО08-15-2001 01:19 PM
Re: Korn Shell Scripting
You can use the "find" command (do: man find, to find more about the options you can use with this command, there is options you can use to select files depending on a creation/modified date,....).
Example, to list all files named *.txt that have not been accessed for a week... do the following command:
find / -name '*.txt' -atime +7 -exec ls -la {} \;
The "{}" will trap the files found in the find command and use this as the input list...
You can integrate your specific commands in the exec statement....
Hope this will help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2001 03:03 PM
тАО08-15-2001 03:03 PM
Re: Korn Shell Scripting
How about having your script write a ftp configuration (I'm not sure what is is actually called) file. You could do something like this. I would just have it create the ftpconfiguration file and use it to ftp the files you need.
CURRDATE=`date +"%b %e"`
FTPCONFILE="/tmp/ftpconfig"
FILELOCATION="/home/jwestgat"
FTPDESTDIR="/tmp"
FILELIST=`ls -al $FILELOCATION | grep "$CURRDATE" | tr -s " " " " | cut -f9 -d "
"`
echo "open hostname" > $FTPCONFILE
echo "user username password" >> $FTPCONFILE
echo "binary" >> $FTPCONFILE
for FILE in $FILELIST
do
echo "put $FILELOCATION/$FILE $FTPDESTDIR/$FILE" >> $FTPCONFILE
done
echo "bye" >> $FTPCONFILE
ftp -vin < $FTPCONFILE
Give it a try, and I hope it helps,
Jared
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2001 12:24 AM
тАО08-17-2001 12:24 AM
Re: Korn Shell Scripting
Thanks a zillion for the help.
I have coded my scripts and when i run it , at the FTP prompt, the below is the message that i got, any idea?
***********
Sending files ....
Connected to
220 Anonymous FTP Server Ready
331 Hello joyce, mail me at softhead@online.no in case of trouble
230 User joyce logged in to server
We only support non-print format, sorry.
?Invalid command
.
.
.
********************
The scenario is I am using FTP to send files from my HPUX box to a windows 98 pc. At the windows pc , i have installed a ftp server to enable this action.
My script is something like below:
////////////////////////////
#in the hpux server
DIR="/tmp"
#in the windows 98 machine
FILEDES="/tmp"
FILELIST=`ls -al $DIR | grep "$dd" | tr -s " " " " | cut -f 9 -d " "`
# FTP file from Billing Server
ftp -n -v
for FILE in $FILELIST
do
put $DIR/$FILE $FILEDES/$FILE
done
bye
////////////////////////////
Please do advice
Thanks in advance
Regards
Joyce
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2001 03:34 AM
тАО08-17-2001 03:34 AM
Re: Korn Shell Scripting
You are getting the following error as you are using "for" statement in your ftp-text.
- "We only support non-print format, sorry. "
The input that is given to 'ftp' must contain only the text that can be understood by ftp.
Try modifing your script as follows:
////////////////////////////
#in the hpux server
DIR="/tmp"
#in the windows 98 machine
FILEDES="/tmp"
FILELIST=`ls -al $DIR | grep "$dd" | tr -s " " " " | cut -f 9 -d " "`
FTP_TEXT=/tmp/ftp_text
echo "user
for FILE in $FILELIST
do
echo "put $DIR/$FILE $FILEDES/$FILE" >>$FTP_TEXT
done
echo "bye " >>$FTP_TEXT
ftp -niv
////////////////////////////
If you need to add some more parameters use echo appropriately and insert the contents to the FTP_TEXT file.
Hope this works and helps.
Jagadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2001 03:38 AM
тАО08-17-2001 03:38 AM
Re: Korn Shell Scripting
If you feel not to involve one more text file(/tmp/ftptext) as ion my previous response,
try this alternative
////////////////////////////
#in the hpux server
DIR="/tmp"
#in the windows 98 machine
FILEDES="/tmp"
FILELIST=`ls -al $DIR | grep "$dd" | tr -s " " " " | cut -f 9 -d " "`
( echo "user
for FILE in $FILELIST
do
echo "put $DIR/$FILE $FILEDES/$FILE"
done
echo "bye"
) | ftp -niv
////////////////////////////
Hope this works and helps.
Jagadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2001 07:03 AM
тАО08-17-2001 07:03 AM
Re: Korn Shell Scripting
I really like your second example. I never thought doing it like that.
Joyce,
Jagadeesh is correct. You will either have to send the text to a file, like in mine and Jagadeesh's examples, or you can do it like Jagadessh's last example.
The problem is that when you specify "<
What you want is for the script to execute the for loop, and send its results to FTP. You should be able to use either solution to do this for you.
Best of luck!
Jared