Winter in Yosemite. March 2015

Generally I try to do a couple of winter trips. Real ones – with camping in the snow. This year’s winter trips were either rainy or too warm. The trip a couple of weeks prior to Ludlow Hut was very wet with cold rain pretty much dominating the weather. However, by this time (early March) the weather became quite warm – almost as warm as in late spring. Yosemite would be a good place to go, however, the regular Yosemite winter route – Badger Pass to Glacier Point – was outright closed, let alone plowed. Lassen NP could be a good choice. But it is a bit far.

My friend Girish had a childcare-free weekend so, mostly, he had to come up with something to backpack on a short notice. As a result, Yosemite worked fine. In fact we could have done some very nice summer routes without the hassles of crowds and permits (the permit was self-issue at the entrance). The planning for this trip was a bit last minute. I actually had to pack on Friday evening a hour before start. It was a bit more stressful for me than usual, but I managed.

Friday, March 6, 2015

DSC_5375

Stars Above El Capitan

Driving was through Fremont where my team member leaves. It was on the way and since he would be driving I was obligated to go there. It wasn’t too bad and we made it to Yosemite by about midnight. The air was clear and crisp, but there was no sign of snow. However, there was enough light to make some night photos. We picked a site in one of the walk-in campgrounds and settled for the night. Again, this would have been an impossible feat to do in Summer.

Saturday, March 7, 2015

Beautiful weather in the morning. Very early morning. Since we arrived to Lower Pines campground a bit late the only empty site we could find was on the way to the toilet. As a result the other residents, who probably went to bed earlier,  started using it very early in the morning. Then those giant Yosemite ravens started most probably looking for food and discussing something with each other. Regular campground life. We broke the camp and headed to Curry Village for some food and campground payment.DSC_5402

We reached the designated 4 mile trail at about 11AM. A bit late, but doable. Left the car just on the side of the road with the full view of Yosemite falls and headed up. Nice. I fish this park was like that in Summer.

The trail was reasonably crowded. We met one group of “campers” going down (they really stayed at the hut). The rest were just day-hikers. Since we started a bit late most of the people were already going down. We, on the other hand, were slowly progressing upward. We had to carry quite a bit of weight, especially all the water for two days.

DSC_5431We reached Glacier Point at reasonable time – still light and sooner than I expected. There were still some people walking around. It was a bit strange looking for a place to put our tent. Generally this area is used as a viewpoint in Summer. Essentially it is a parking lot. In normal Winter it is covered by snow so it doesn’t look like a parking lot and have no people. Now – it was like camping at a vista point in a national park. Doable but weird. Eventually we picked the little hut designated as a Geology Hut. Luxurious, with even better view. There was just a little problem which we would find later.

Closer to sunset the day-hikers disappeared. There were a couple more people staying overnight. However, there was no-one in the Ski Hut. In fact it was open so we could have just stayed there. But then it wouldn’t be camping.

DSC_5496

We did a lot of different night photography after dusk (memory is cheap), before full moon came up and flooded everything with light. It was nice and not cold at all.

Sunday, March 8, 2015

Camping at the Geology Hut turned out to be not that much fun. It had very nice springy wooden floor that transferred any movements everywhere. As a result, I could really feel any Girish’s movements and especially his walking. He got up early to get some dawn photos that I’m yet to see.

DSC_5507After simple breakfast we slowly started down. There was no rush – just 4 miles all downhill. We saw the first person right below the rim of Glacier Point. It was kind of early. But it turned out that this day was the time change. We saw some people climbing uphill while enjoying easy hike down. We made it to the car by 1PM or so. It was still there on the side of the rad without any ticket.

It was a nice trip. The sad part was that this nice trip was made possible by almost complete lack of snow this season.


Photos.

Posted in Trip Reports, Wilderness, Winter Trips | Tagged , , | Leave a comment

Winter Trip to Ludlow Hut. Feb 2015

Once again the California drought, exacerbated by the climate change, is messing up our snow supply. Not only did we have only a couple of real storms, but the snow also fell as rain. People here were watching, longingly, at the feet of beautiful snow that inundated the North-East.

Somehow I managed to get in touch with one of the Sierra Club leaders. In particular a leader who primarily leads winter trips. I’ve asked him about some trip requirements what looked quite technical. After that he asked me if I want to come on this trip. The weather reports promised nasty cold rain, which is actually much worse than snow, but I didn’t want to say no. We were also not camping, but staying in Ludlow Hut, which could somewhat mitigate the bad weather. In the end there were only three people in the group, mostly due to the incoming rain.

Friday, February 5, 2015

Starting the regular driving. The leader graciously agreed to drive his Subaru in the rainy weather, which would behave much better than my Prius. Not only that, he also let us stay at his parents’ cabin in Truckee area (and thus he probably knows the area much better making for efficient drive). We stopped at Dairy Queen for some supper. I never knew they sell sandwiches. The name Dairy Queen generally brings up images of ice-cream or milk shakes.

By the time we reached Tahoe the heavy rain turned into wet snow. Highway 80 was slowly moving. The CHP blocked the parallel streets to all traffic except the local access. Our leader had to tell them that he lived locally. We were wondering why CHP did that. One idea was that Google maps was probably rerouting people around the main blocked area. However, there was still danger in driving on new snow without chains and CHP was trying to enforce this.

The leader’s family had a simple mountain hut – an A-frame but with all the amenities. Lovely place to stay during Summer or Winter. Just have to mind increasingly smart neighborhood bears.

Saturday, February 6, 2015

The morning weather looked fine. At least nothing was coming down. After a simple breakfast and release signage we headed to the trailhead – McKinney-Rubicon trail, which is apparently world famous. By the time we found a place to park it was actually sunny! Lovely. That would have been a very nice weather.

DSC_5294

Ludlow Hut

We parked a bit away from the main trail head. It was, however, occupied by the smelly 4-wheelers. The main trail was more like a road. It was expected – a similar forest road was leading to other huts. I gather it was also needed for the 4-wheelers. They probably could hammer through the forest, but that would eventually create a road anyway. Yesterday’s snow added a lot of water all over. We have to almost do a couple of river crossings. The weather slowly turned by the time we reached the hut. It was actually snowed very well.

I was happy to settle in the hut and watch the snow falling. It had everything needed, except solar lights. However, the other members wanted to hike up some local mountain (Lost Corner Mountain) and I had to go with them. I didn’t want to look weak even though the weather looked more and more nasty.

We reached the peak fine – hiking up a snowy mountain on snow shoes isn’t that hard. But there was nothing to see except very thick fog. Oh well. By the time we reached the hut everything was wet. At least there was a decent stove with some ability to dry things out.

We spent the rest of the day in the hut burning one of the stoves and drying the equipment. Wet snow was falling periodically with more or less rain. Somehow Sierra Club has this tradition that a trip leader would actually bring and cook the dinner for the group. Very nice. I’m a bit lazy with my trips. But probably the difficulty comes from negotiating what people want to eat. If everyone was no picky with food it would have been a lot easier, but that generally isn’t the case.

Sunday, February 7, 2015

Morning was semi-clear – cloudy, but nothing was falling down. Again the team wanted to do a dayhike.DSC_5326The view was better this time, but it was clear that a change in weather was coming. By the time we reached the Hut it was snowing again.

The slog back to the car was nasty. It really started coming down mostly rain. I suppose dry cold snow would have been fine, but that wasn’t the case. I was drenched, completely. Even my socks were wet. Somehow I managed to keep the insides of my pack dry. Thankfully the leader wasn’t particularly picky about getting his Subaru wet. I brought some change of clothes, but not that much. Also, changing outside under rain would make new closes also wet.

It was sad that the weather wasn’t really wintery. But other than that it was a nice trip. And I also located one more of the Sierra Club Huts. It could be useful for future visits. Ans I med a cool Sierra Club snow trip leader. Perhaps we can do more trips in the future.


Photos.

Map.

Posted in Trip Reports, Wilderness, Winter Trips | Tagged , , | Leave a comment

Winter in Chester. December 2014

The long trip this year was out of question. Sad. As a result I was looking for some nice place to spend the holidays. Something homy with lots of snow and good food, preferably not too far. I like the state of Oregon and I also like B&Bs. So it would be nice to spend Christmas weekend in some cabin far away in the snowy woods, with good food and skiing. I’m not sure if it even possible. Still, I couldn’t find anything reasonable. The places were either too expensive, too remote, or already booked or closed.

Bidwell House DrawingSo after some extensive searches I found a place called Bidwell House in Chester, CA. They were closed on Christmas holiday, but seem to fit all the rest of the parameters. The house was really cute. And with all the recent storms I was really looking forward to the winter cabin like experience. The place actually had a web camera to look outside on their green yard where the Summer weddings are held. Initially it was covered by wet snow, but by the time Christmas ended the snow melted and it was all green grass again.

Surprisingly, we were not the only people staying at the same time. But the place was empty with only a couple of rooms rented. I’ve picked the cheapest one called McKenzie Suite A. Not because I’m such a cheap skate (which I am), but because it was a top floor small room. Just good enough for two nights.

Friday, December 26

The B&B hosts actually required in the reservation the time we would be arriving. Why, you may ask, they set this restriction since I’m paying for it and a regular boring Hotel usually open 24/7. Well, generally good B&Bs are someone’s houses. As a result it is not reasonable to expect people to attend to your every wish, including late arrival, because of that. Fensalden Inn people, for example, were actually very particular and were waiting for us to come, to give keys to the room and the house and such. As a result we had to leave Sunnyvale in the morning. I was also not cooking forward to driving at night.

Initial traffic out of Bay Area was heavy. I suspect people were trying to take advantage of holidays, good weather, and fresh snow at Tahoe. However, after about Richmond the freeway became clear – no one really wanted to go to Lassen NP I suppose.

We’ve gotten to deserted Chester almost by the nightfall.  The last parts of the drive were a bit iffy due to the freezing temperatures and some small amount of black ice. The Bidwell House was deserted too, as expected. However, it was open. There was another outdoorsy looking couple in the house who also just arrived. They showed us an envelope with keys to our room and the rules. That was it. It seems as if anyone can come and stay. Only later I found that there were many cameras installed around the house. On the other hand no one really would be wondering around freezing Chester in winter.

DSC_5121

The Bidwell House was nice. Large old house (though it was moved when the lake Almanor was created) with giant fireplace that had lots of Christmas little houses on it. There was also a local gorgeous outdoor cat. We found her wandering around the grounds in the freezing cold, which didn’t seem to bother her. She had so much lush colorful fur to protect against the cold that she probably felt fine. I’ve let her inside.

There was also lots of magazines to read, local activity and historical books, tea and coffee, and sherry, but no chocolate covered almonds. Aside from no snow it was just what I expected.

For dinner my other half selected a Chinese place – highly recommended Happy Garden. Well, it seemed that the reviewers had no idea how the real Chinese food taste like. And the restaurant owners were happy to change their cuisine to fit the local perverted ideas. Since I knew how Chinese food taste the Happy Garden was way a disappointment. Seriously, never expect a good ethnic food in small towns that are not populated by the said ethnicity.

Saturday, December 27

Beautiful bright freezing morning. Best time to go visit some nature. We had great breakfast at the B&B appropriately. It included omelet, juice, and dessert served by very friendly hired staff. Interestingly they had many different types of forks for different dishes in the meal. Very classy. We had a good chat with the other couple staying in the inn. They were also surprisingly from Sunnyvale. They were visiting all the national parks in California. I believe Lassen was their last. Very sporty people. But they were complete newbies to backpacking.
DSC_0080Among all the activity literature that the B&B had I finally found the one that we could both do – Lake Almanor recreational trail. The trail followed the West side of the like and was mostly flat. Surprisingly there were many trails around. In the National Park, of course, but also in many Forest Service lands around. Our fellow guests went to see some waterfall North East of Lassen. It just required several hours of driving.

Outside the town of Chester was sunny, cold and deserted. Maybe people went away for Christmas. It was possible that the lake Almanor surroundings were just tourist resort type of place. As a result, it was deserted during Christmas weekend. How nice. One down side was that there was pretty much zero snow.
DSC_5136
Obviously I had t miss the trailhead. It was right off the CA-89. Instead I went to some gated lakeside summer houses. But eventually I found a spot that looked like a parking lot about a mile off the proper trailhead.

The Lake Almanor recreational trail was mostly flat, clean, wide, and paved. It would probably be great in summer on a bike. Especially if you are staying in one of the those campgrounds on the shore.

Lake Almanor was low. It was clearly visible. About 4 feet low. There was no snow, but there were different frozen entities in the forest like some old frozen mushrooms or ice covered logs. All in all we did about 12 miles of hiking.

We cam back right at sunset. This day I was really looking forward to some good local food. The B&B had some recommendations and the best looking one was Red Onion Grill. Little dd I know that the person who ran (and maybe owned) the Bidwell House also owned the said restaurant. Well, the B&B was ran fine, so the restaurant should be too, though the food quality depends a lot on the cook.

I’ve ordered some giant egg burger and Rita had lamb again. The burger was good, just too large. So big that I didn’t have space for dessert. Restaurant was very sparsely decorated. It had good sized outside patio with some view of the lake. It was probably very nice in summer. Now it was all dark and cold.

After dinner I walked around Chester a bit to shake that burger down. It was cold and dark and deserted.

Sunday, December 28

My plan was just to drive back – days were short and the drive was long. I found this scenic California highway 70 called Feather River National Scenic Byway that looked interesting and on the way. The breakfast was good – tasty and different from the day before. The Bidwell House seemed to be a popular place. The lady there told us that they were booked for every weekend in Summer for the weddings. It was a nice place to have a wedding.

DSC_0089The drive was great. Feather river road was not busy, clean, sunny, with many stop points to see the tamed feather river. One of our power companies dammed the hell out of it – there were power stations one after another almost entirely removing all the beauty out of this natural river. At least they didn’t make another Lake Almanor size reservoir. In a couple of places there were small hot springs coming out of sheer rock. In addition to that I managed to hike PCT, a very short section.


Photos.

Posted in Leasure, Travel | Tagged | Leave a comment

Thanksgiving in Mendocino. Thanksgiving 2014

Once again we are spending Thanksgiving around Bay Area not-backpacking. Last year we went to Mendocino. Also due to the same reason. How sad. Perhaps I should figure out some sort of interesting route in the Southwest that could be done in 3 or 4 days. Winter is not the nicest time, but going there during the best time – March – is a bit difficult (vacation time).

The Thanksgiving Day itself was spent in semi-idle resting. Rita had some patients in the morning and we went to see the Hunger Games afternoon to the local movie theater which was for some reason working. At least there were no problems with tickets.

Friday, November 28

We visited our friends for a post-Thanksgiving gathering and then headed to the rain in Mendocino. Rita wanted to try different places instead of the lovely Fensalden Inn we stayed in last year. As a result she picked two different places – one in Mendocino proper and one in Fort Bragg. None of them B&B, which was sad to me. All hotels, in the world, are more or less the same. B&Bs at least have some uniqueness in them.

Since we started a bit late right after sunset I had to drive through the night into the upcoming rainstorm on the never-ending highway 128. That drive is nice in good weather. But with the wall of rain in the dark it wasn’t much fun. At least it was empty except for several frogs who enthusiastically tried to cross it. They were really lit up in the headlights. I hope I didn’t kill anyone. Eventually the drive ended at the expansive Mendocino Hotel, which was the accommodation for the day.

The hotel was very old bar/staging place/hotel. It was also probably brothel at some point. Old, of course, was by Mendocino standards. It had a lively restaurant with was bustling with activities at the dark time when we arrived there. At some point the owners also acquired some more places around because our humble room was in a house across the street. There was nothing special about it other than color broken TV and working fireplace. The hotel provided two of those per-packaged artificial logs and matches. The logs were easy to light, but they didn’t really want to create a good fire.

Saturday, November 29

Since this hotel didn’t provide any food in the morning we had to scramble. The good thing was that Mendocino had several very nice coffee shops within walking distance. Well, technically the whole town is within walking distance.

DSC_0036

Art

Mendocino is tiny. There is a nice ocean view trail, lots of little galleries and specialty shops, and some restaurants. That was pretty much what we were doing there the first half of the day. I liked some works. There were many very beautiful photos. Some were just weird or too expensive. After lunch we visited the currently being held art festival. Then headed North to Fort Bragg.

DSC_4943

By this time the short late November day was already over. But it was just the right time for the attraction of the day – Festival of Lights in Mendocino Coast Botanical Gardens. They really lit up the place with very elaborate and creative light installations. Some of the stuff, like this dragon, was also moving. The garden also had a large fire pit with provided marshmallows to roast. There was also a pavilion with guitar music and hot cider and vine. Very nice. Good thing that by that time the on and off rain of the day had subsided.

The difficult part was to find a place to eat. Mostly because of too much information. One can pull up Yelp and find several places around. But then their rating were that good, which may or may not be true. People like or not all sorts of things. Eventually we settled on Herons by the Sea for some seafood. There wasn’t a whole lot of choices and I didn’t want to drive South to the fancier places there. The food in Herons by the Sea was OK, that is after we found the place. I just had this slight suspicion that it wasn’t the best quality and probably laden with chemicals. Like the Mexican cooks there didn’t care for it. The place also looked shabby and cheap – like a McDonald’s.

Sunday, November 30

Morning in rainy Fort Bragg was a bit slow. The whole downtown was close aside from one or two places that were packed with hungry people. The wait time was about 30 minutes. I was tempted to just drive down to Mendocino for their food. Yelp again directed us to this highly recommended place called David’s Restaurant. Yes, it was highly efficient and clean. But the food was just regular diner food same as in Denny’s. The people there all seem to know each other. I had an impression that they all came to this place after Sunday church. After this we headed South.

The rain stopped and left this beautiful clear weather. It was like it washed away all the dirt and smog. The sky was the usual after-rain eventful – clouds and some sun. Much more interesting than clear blue.
DSC_0049The main goal, aside from getting home, was to stop for some mushrooms. There should be lots of them with all that water. There were some at this park with a beach access, but the main place to see was the Salt Point State Park. This was the place we visited 2 years ago and gotten some training on mushroom picking.

DSC_0064

One Boletus

Well, we were not the only people with mushroom picking idea. In fact Mendocino had some sort of even just a week prior all about mushrooms. There was even one place serving wild mushrooms soup, but they were out when we asked them. But this also meant that the Salt Point State Park was stripped clean. We could see trails that people made in the grass. I did manage to find two Boletus and many slippery jacks. Enough for one dinner, if I knew how to cook them best.

There was one park ranger who stopped to probably check on Rita in the car while I was coming down the hill. I was afraid he’d give a ticket. But he checked my two mushrooms and said that it will be enough for a dinner. He was the one who mentioned about all the people in this park.

Then it was all drive back. Good thing it was still light so that I could enjoy the ride. We stopped at Bodega Bay for gas. The gas station was old. The station attendant used binoculars to read the numbers of the machine from the shop building.


Photos:

Posted in Leasure, Travel, Trip Reports | Tagged , | Leave a comment

Desolation Wilderness Trip Report. Oct 2014

Another short backpacking trip to Desolation Wilderness, this time in Autumn.

Originally I wanted to have a birthday trip – just a short trip as gift to myself. Then for some reason I decided to lead it and then it suddenly became very complicated. I could barely find permits for the area I wanted to go to. Then there was the King fire on the West side of Desolation. Due to the prevailing winds it covered Lake Tahoe with enough smoke to be a health hazard. As a result the trip had to be postponed a week moving it into October. The good thing about the postponement was that by that time the camping quota was lifted.

Then the group presented a bit of a challenge. The trip was re-posted on the Indian Adventures MeetUP group. As a result out of 12 people in my group 9 were Indian men not all of them with experience. At least we had two women to dilute the gender ratio a bit.

Friday, October 3

Regular weekend trip start – just drive to Tahoe in the evening after work. I was carpooling with Parul and Kaori. Fallen Leaf Campground was not busy this time of the year. Though I’ve managed to miss it a couple of times it in the dark.

Saturday, October 4

The morning was sunny if crisp. Good weather. Tahoe had a couple of inches of wet snow a week or so before. But it was all gone. All of my gang have made it. Now we had to get some food, check the gear, and perhaps pick up some lost items. Right there I noticed that my group wasn’t exactly thrilled about sleeping outside. There was no rain coming so I just put my pad and slept on the ground. But some of the guys were visibly uncomfortable this cold morning.

As it became a tradition I found an interesting coffee place to have breakfast – Keys Cafe. I’ve gotten some huge insanely sweet Belgian waffle from there. Barely digesting all that sugar I ran through the gear list. Everyone seemed to have taken all the necessary gear. This is where I’ve made the same mistake – just because something is called a “sleeping bag”, it doesn’t mean it is the right sleeping bag. One dude brought the same proverbial WalMart  sleeping bag attached to a school backpack. Why did I post this trip again?

DSC_4604

Lake Aloha

The Fallen Leaf trailhead was actually busy. We barely managed to find space. It was a popular place for some day hikes, plus we were also starting a bit late.

Beautiful day. Crisp, clear, dry. A bit too dry for this time of the year. It was hard to see on Tahoe itself, but it was visible on the smaller lakes that the water level was low. We did quite an uphill the first half of the day. The group was struggling. Someone brought a bug of cuties. Tasty, but heavy.

We lumbered to our destination – Clyde Lake – by nightfall. There was a small group there already, but they occupied a flat area a bit away from the lake. We just took over the main flat rocky area right on the shore. This place was already improved. There were a couple of rock walls to shield from wind and some old fire pits. Clyde lake is actually rather small. I suspect that our large inexperienced group severely damaged the environment there, mostly with the human “results”. Processing of those “results” is a bit slow in our dry climate. I tried to teach the crew how to “do it” in the woods properly, but I’m not sure how many actually followed.

DSC_4643

Starry Sky

After dinner, which was sometimes interesting, we had this glorious starry sky. People were kind of separated into groups. Too bad we didn’t have a fire, but they were enjoying themselves. I didn’t really feel in place. I tried doing some night photography, but without timer and tripod my options were rather limited.

Sunday, October 4

Get up and go back. Crispy autumn morning caused a bit of a slow moving. There wasn’t much rush to get back, at least from my standpoint since the mileage wasn’t that high. This, however, proved detrimental. First the green group was slow. Second – people just get lost a couple of times. Seriously? Some of them just failed to follow the well traveled trail. Then they didn’t find anything better to do than yell “help”. Perhaps even this very easy trip was too much as an introductory.

DSC_4699

Lake Tahoe from Mt Tallac

We did, however, went up to Mt Tallac for the gorgeous view of Lake Tahoe. The approach from the West to Tallc summit was much easier than from Tahoe basin. We were probably also well acclimatized already. It was just a simple persistent climb, not much work without the backpack.

We made it to now deserted parking lot after dark. Some people were really happy for this trip to be over. But they did pay for the expenses. With all that mountain climbing and fairly warm October weather I was severely dehydrated. Luckily Kaori found a good ramen place somewhere in Davis so that we could replenish the lost salts and water.

Photos.

Map.

Posted in Trip Reports, Wilderness | Tagged | Leave a comment

One command ftp with error reporting

In the previous post I’ve wrote a one line ftp control using expect. It looked pretty good and it worked. Then I stumbled upon curl … and I had to rewrite the script. With curl the entire script could be made much simpler and faster. Here it is:


#!/bin/bash
#
# Curl array ftp wrapper
#
# ftp to/from <system> as user ftp

verbose=0

usage() {
    echo "Transfer files using ftp"
    echo "usage: `basename $0` [-v] get <system> <remote file> <local file>"
    echo "       `basename $0` [-v] put <system> <local file> <remote file>"
    exit 1
}

if [ "$1" == "-h" -o "$1" == "-?" ]; then
    usage
    exit 1
fi

if [ "$1" == "-v" ]; then
    verbose=1
fi

num_arg=`expr $# - $verbose`
if [ $num_arg != 4 ]; then
    usage
fi

args=("$@")
cmd=${args[`expr $verbose + 0`]}
target=${args[`expr $verbose + 1`]}
file1=${args[`expr $verbose + 2`]}
file2=${args[`expr $verbose + 3`]}

if [ "$cmd" != "get" ] && [ "$cmd" != "put" ]; then
    echo "Invalid command '$cmd'"
    usage
fi
if [ "$cmd" == "put" ] && [ ! -e $file1 ]; then
    echo "Source file $file1 doesn't exist"
    exit 1
fi

# set the verbose variable
curl_verbose="-s"
if [ $verbose == 1 ]; then
    curl_verbose="-v"
fi

if [ $cmd == "get" ]; then
    if [ $verbose == 1 ]; then
        echo "Copying file from $target:$file1 to $file2"
    fi

    curl $curl_verbose ftp://$target/$file1 --user ftp:ftp -o $file2

else
    if [ $cmd == "put" ]; then
        if [ $verbose == 1 ]; then
            echo "Copying file from $file1 to ftp://$target/$file2"
        fi

        curl $curl_verbose -T $file1 ftp://$target/$file2 --user ftp:ftp

    else
        echo "Invalid command"
        if [ $verbose == 1 ]; then
            usage
        fi
        exit 1
    fi
fi


References:

Posted in Computers, Linux | Tagged , | Leave a comment

Expect ftp with error reporting

I had a problem that required automating access to the ftp file transfer. This could be resolved with a simple expect script. There are many expect scripts on the net. However, they are all seem to be overly optimistic with the results. I wanted a script that could handle different errors that could occur during ftp operation. So I wrote my own (or improved someone else’s script). Here it is. Any constructive comments are welcome.


 #!/usr/bin/expect
 #
 # Expect ftp wrapper
 #
 # ftp to/from system as user ftp

 set timeout 10
 set verbose 0
 proc usage {} {
     puts "Transfer files using ftp"
     puts "usage: eftp [-v] get <system> <remote file> <local file>
     puts "       eftp [-v] put <system> <local file> <remote file>
     exit 1
 }

 if {[lindex $argv 0] == "-h" || [lindex $argv 0] == "-?"} {
     usage
 }
 if {[lindex $argv 0] == "-v"} {
     set verbose 1
 }

 set num_arg [expr [llength $argv] - $verbose]
 if {$num_arg != 4} {
     usage
 }

 set cmd     [lindex $argv [expr $verbose + 0]]
 set target  [lindex $argv [expr $verbose + 1]]
 set file1   [lindex $argv [expr $verbose + 2]]
 set file2   [lindex $argv [expr $verbose + 3]]
 
 if {$cmd != "get" && $cmd != "put"} {
     puts "Invalid command"
     usage
 }
 if {$cmd == "put" && ![file exists $file1]} {
     puts "Source file $file1 doesn't exist"
     exit 1
 }

 exp_log_user 0
 if {$cmd == "get"} {
     if {$verbose} {puts "Copying file from $target:$file1 to $file2"}
 } else {
     if {$cmd == "put"} {
         if {$verbose} {puts "Copying file from $file1 to $target:$file2"}
     } else {
         puts "Invalid command"
         if {$verbose} { usage }
         exit 1
     }
 }

 set ftp_result 0
 spawn ftp $target
 set timeout 2
 expect {
     "Name ($target:admin):" {
     }
     timeout {
         puts "Error connecting to $target"
         exit 1
     }
 }
 send -- "ftp\r"
 expect "Password:"
 send -- "ftp\r"        # change to your password
 expect "ftp> "
 send -- "binary\r"
 expect "ftp> "
 send -- "prompt\r"
 expect "ftp> "
 set timeout 40

 send "$cmd $file1 $file2 \r"
 expect {
     "227 Entering Passive Mode" {
         if {$verbose} { puts "Start transfer" }
     }
     "local: $file1: No such file or directory" {
         puts "Local file $file1 is missing"
         set ftp_result 1
     }
     timeout {
         puts "timeout on start"
         set ftp_result 1
     }
 }

 expect {
     "150 Opening BINARY mode data connection" {
     }
     -re {(\d+\s)(.*\n)} {
         puts "ftp error occurred: '$expect_out(1,string) [string trim $expect_out(2,string)]'"
         set ftp_result 1
     }
     timeout {
         #puts "timeout2"
         set ftp_result 1
     }
 }

 if {0 == $ftp_result} {
     expect {
          "226 Transfer complete." {
              if {$verbose} { puts "Transfer complete" }
          }
          timeout {
              #puts "timeout2"
              set ftp_result 1
          }
     }
 }

 expect "ftp> "
 send "quit\r"
 expect "Goodbye."

 exp_wait
 if {$verbose} { puts "Result $ftp_result" }
 exit  $ftp_result

Posted in Computers, Linux | Tagged , | 1 Comment